Commit 01f0447c authored by Maxime Bombar's avatar Maxime Bombar

Revert "Merge branch 'master' of gitlab.crans.org:esum/NinjaBot"

Oupsi

This reverts commit ee385852, reversing
changes made to b9963534.
parent ee385852
......@@ -94,9 +94,9 @@ UPDATES = {
)
}
class Nsa(Bot):
class Ninja(Bot):
def __init__(self):
Bot.__init__(self, "NsaBot")
Bot.__init__(self, "NinjaBot")
def on_welcome_ext(self, conn, e):
conn.join('#wikistalk')
......@@ -184,13 +184,9 @@ class Nsa(Bot):
@asyncio.coroutine
<<<<<<< HEAD:src/nsabot.py
def idle_loop(host, user, password, nsa):
=======
def idle_loop(host, user, password, ninja):
global UPDATES, DEFAULT_SENDER
>>>>>>> b9963534ec17e245f5dc1d5fc9ef5ff488dedd87:src/ninjabot.py
imap_client = aioimaplib.IMAP4_SSL(host=host, timeout=30)
yield from imap_client.wait_hello_from_server()
yield from imap_client.login(user, password)
......@@ -205,24 +201,6 @@ def idle_loop(host, user, password, ninja):
if m.endswith(' EXISTS'):
mail = yield from imap_client.uid('fetch', m[:-7], '(RFC822)')
mail = email.message_from_bytes(mail.lines[1])
<<<<<<< HEAD:src/nsabot.py
body = quopri.decodestring(mail.get_payload()).decode('utf-8').replace('\r', '')
page_user = re.search(r'La page « (?P<page>.*) » a été modifiée par (?P<user>.*) :', body)
revision = re.search(r'\?action=diff&rev1=[0-9]+&rev2=(?P<rev>[0-9]+)\n', body)
comment = re.search(r'\s*Commentaire :\s*\n\s*(?P<comment>[^\n]*)\n', body)
if comment: comment = comment.group('comment')
if page_user:
nsa.push_update(page_user.group('page'), page_user.group('user'), int(revision.group('rev')), comment)
continue
page_new_user = re.search(r'La page « (?P<page>.*) » a été renommée « (?P<new>.*) » par (?P<user>.*) :', body)
if page_new_user:
nsa.push_update(page_new_user.group('page'), page_user.group('user'), page_new_user.group('new'), comment, type=Update.rename)
continue
page_user = re.search(r'vous vous êtes abonné aux notifications de changements pour la page "(?P<page>.*)"\.Une pièce jointe (?P<add>(?:vient d\'y être ajouté)|(?:de cette page vient d\'être supprimée)) par (?P<user>.*)\. Quelques détails sur la pièce jointe :', body)
piece = re.search(r'Nom\s*:\s*(?P<name>[^\n]*)\n', body)
if page_user:
nsa.push_update(page_user.group('page'), page_user.group('user'), piece.group('name'), "ajout d'une pièce jointe" if page_user.group('add').startswith('v') else 'suppression de la pièce jointe', type=Update.attachment)
=======
sender = mail['From']
if sender not in UPDATES:
sender = DEFAULT_SENDER
......@@ -247,21 +225,16 @@ def idle_loop(host, user, password, ninja):
message = message(**kwargs)
page = kwargs[page]
ninja.push_update(page, message)
>>>>>>> b9963534ec17e245f5dc1d5fc9ef5ff488dedd87:src/ninjabot.py
if __name__ == '__main__':
loop = asyncio.get_event_loop()
nsa = Nsa()
t = threading.Thread(target=nsa.start)
ninja = Ninja()
t = threading.Thread(target=ninja.start)
t.start()
while True:
try:
<<<<<<< HEAD:src/nsabot.py
loop.run_until_complete(idle_loop(secrets.host, secrets.user, secrets.password, nsa))
=======
# Des fois ça timeout et je ne sais pas pourquoi, d'où le while True
loop.run_until_complete(idle_loop(secrets.host, secrets.user, secrets.password, ninja))
>>>>>>> b9963534ec17e245f5dc1d5fc9ef5ff488dedd87:src/ninjabot.py
except:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment