add keywords and enhance fetching of board messages
This commit is contained in:
parent
16be6df4d0
commit
4006506292
1 changed files with 13 additions and 11 deletions
|
|
@ -50,7 +50,10 @@ class MyThread(Thread):
|
||||||
self.weboob.loop()
|
self.weboob.loop()
|
||||||
|
|
||||||
def find_keywords(self, text):
|
def find_keywords(self, text):
|
||||||
for word in ['weboob', 'videoob', 'havesex', 'havedate', u'sàt', u'salut à toi']:
|
for word in ['weboob', 'videoob', 'havesex', 'havedate', 'monboob', 'boobmsg', \
|
||||||
|
'flatboob', 'boobill', 'pastoob', 'radioob', 'translaboob', 'traveloob', \
|
||||||
|
'boobathon', 'boobank', 'boobtracker', 'comparoob', 'wetboobs', \
|
||||||
|
'webcontentedit', 'weboorrents', 'capabilit', u'sàt', u'salut à toi']:
|
||||||
if word in text.lower():
|
if word in text.lower():
|
||||||
return word
|
return word
|
||||||
return None
|
return None
|
||||||
|
|
@ -64,16 +67,15 @@ class MyThread(Thread):
|
||||||
backend.set_message_read(msg)
|
backend.set_message_read(msg)
|
||||||
|
|
||||||
def check_board(self):
|
def check_board(self):
|
||||||
try:
|
def iter_messages(backend):
|
||||||
backend = self.weboob.backend_instances['dlfp']
|
with backend.browser:
|
||||||
except KeyError:
|
return backend.browser.iter_new_board_messages()
|
||||||
return
|
|
||||||
|
|
||||||
with backend.browser:
|
for backend, msg in self.weboob.do(iter_messages, backends=['dlfp']):
|
||||||
for msg in backend.browser.iter_new_board_messages():
|
word = self.find_keywords(msg.message)
|
||||||
word = self.find_keywords(msg.message)
|
if word is not None:
|
||||||
if word is not None:
|
message = msg.message.replace(word, '\002%s\002' % word)
|
||||||
self.bot.send_message('[DLFP] %s talks about %s on the board' % (msg.login, word))
|
self.bot.send_message('[DLFP] <%s> %s' % (msg.login, message))
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.weboob.want_stop()
|
self.weboob.want_stop()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue