Compare commits
No commits in common. "13b9f27994e126d0a92deb794fc62233d9447f3e" and "d8a612b6f6df5dc53ae45348c4a655222436391d" have entirely different histories.
13b9f27994
...
d8a612b6f6
4 changed files with 0 additions and 2717 deletions
2
bot.py
2
bot.py
|
@ -83,7 +83,6 @@ class bot(bare.bot):
|
|||
for line in f.readlines():
|
||||
TMFeed.extend([line.strip().split()])
|
||||
self.markov = MarkovBot(TMFeed)
|
||||
conf.prefix = (conf.servers[server]["prefix"] if "prefix" in conf.servers[server] else ".")
|
||||
self.log(f"Start init for {self.server}")
|
||||
|
||||
def connect(self) -> None:
|
||||
|
@ -321,7 +320,6 @@ class bot(bare.bot):
|
|||
if "interval" in conf.servers[self.server]
|
||||
else 50
|
||||
)
|
||||
conf.prefix = (conf.servers[server]["prefix"] if "prefix" in conf.servers[server] else ".")
|
||||
reload(cmds)
|
||||
reload(handlers)
|
||||
self.msg("Reloaded successfully", chan)
|
||||
|
|
|
@ -67,7 +67,6 @@ servers: dict[str, dict[str, Any]] = {
|
|||
"#firepup650": 0,
|
||||
},
|
||||
"admins": ["firepup650"],
|
||||
"prefix": "!"
|
||||
},
|
||||
}
|
||||
admin_hosts: list[str] = ["firepup.firepi", "47.221.227.180"]
|
||||
|
|
51
markov.py
51
markov.py
|
@ -1,51 +0,0 @@
|
|||
import random
|
||||
from typing import Union
|
||||
|
||||
|
||||
class MarkovBot:
|
||||
def __init__(self, text: list[list[str]]) -> None:
|
||||
self.text = text
|
||||
self.chains = {}
|
||||
self.__build_chains()
|
||||
|
||||
def __build_chains(self) -> None:
|
||||
for i in range(len(self.text)):
|
||||
text = self.text[i]
|
||||
for j in range(len(text) - 1):
|
||||
current_word = text[j]
|
||||
next_word = text[j + 1]
|
||||
|
||||
if current_word not in self.chains:
|
||||
self.chains[current_word] = {}
|
||||
|
||||
if next_word not in self.chains[current_word]:
|
||||
self.chains[current_word][next_word] = 0
|
||||
|
||||
self.chains[current_word][next_word] += 1
|
||||
|
||||
def generate_text(self, word: Union[str, None] = None) -> str:
|
||||
if not word:
|
||||
current_word = random.choice(list(self.chains.keys()))
|
||||
else:
|
||||
current_word = word
|
||||
generated_text = current_word
|
||||
|
||||
while current_word in self.chains:
|
||||
next_word = random.choices(
|
||||
list(self.chains[current_word].keys()),
|
||||
weights=list(self.chains[current_word].values()),
|
||||
)[0]
|
||||
generated_text += " " + next_word
|
||||
current_word = next_word
|
||||
|
||||
return generated_text
|
||||
|
||||
def generate_from_sentence(self, msg: Union[str, None] = None) -> str:
|
||||
if not msg:
|
||||
word = random.choice(list(self.chains.keys()))
|
||||
else:
|
||||
word = random.choice(msg.split())
|
||||
if (for_word := self.generate_text(word)) != word:
|
||||
return for_word
|
||||
else:
|
||||
return self.generate_text()
|
2663
mastermessages.txt
2663
mastermessages.txt
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue