some refactoring, fixed db stuff and help section
This commit is contained in:
parent
c9331151f8
commit
696bf5492b
4 changed files with 70 additions and 29 deletions
|
@ -31,6 +31,7 @@ class Responder:
|
|||
self.apiregex = re.compile(r'^\{(\w+)\}(.+)?$')
|
||||
self.namegen = pgbotlib.misc.NameGenerator(config, db_connection)
|
||||
self.tokens = get_tokens(config['response_tokens'])
|
||||
self.chats = config['chats']
|
||||
self.api = pgbotlib.api.ApiWrapper(self.tokens, db_connection)
|
||||
self.db_connection = db_connection
|
||||
self.client = client
|
||||
|
@ -61,7 +62,7 @@ class Responder:
|
|||
def disable(self) -> None:
|
||||
self.enabled = False
|
||||
|
||||
def enabled(self) -> bool:
|
||||
def is_enabled(self) -> bool:
|
||||
return self.enabled
|
||||
|
||||
def get_response(self, tokens: frozenset) -> str:
|
||||
|
@ -100,6 +101,8 @@ class Responder:
|
|||
event: telethon.events.common.EventBuilder) -> None:
|
||||
if not self.enabled:
|
||||
return None
|
||||
if event.message.peer_id not in self.chats:
|
||||
return None
|
||||
message = event.message.text.lower()
|
||||
tokens = self.tokenize(message)
|
||||
response = self.get_response(tokens)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue