]> PatchyGit - angel.git/commitdiff
Remove commands
authorKylie Czar <czar@kalli.st>
Sun, 16 May 2021 21:40:08 +0000 (18:40 -0300)
committerKylie Czar <czar@kalli.st>
Sun, 16 May 2021 21:40:08 +0000 (18:40 -0300)
main.py

diff --git a/main.py b/main.py
index 1ed11cb..a34ba43 100644 (file)
--- a/main.py
+++ b/main.py
@@ -80,9 +80,6 @@ def get_yurl(path):
 
 
 class AngelBot(ClientXMPP):
-    commands = {}
-    muc_commands = {}
-
     messages = defaultdict(
         lambda: {
             "messages": Lifo(100),
@@ -183,26 +180,6 @@ class AngelBot(ClientXMPP):
             uri = urlparse(u)
             await self.parse_uri(uri, sender, mtype)
 
-    def muc_word(self, func):
-        name = func.__name__
-        self.muc_commands[name] = func
-        return func
-
-    def muc_command(self, func):
-        name = self.prefix + func.__name__
-        self.muc_commands[name] = func
-        return func
-
-    def word(self, func):
-        name = func.__name__
-        self.commands[name] = func
-        return func
-
-    def command(self, func):
-        name = self.prefix + func.__name__
-        self.commands[name] = func
-        return func
-
     def s(self, msg, sender, mtype):
         try:
             text = msg["body"]
@@ -289,9 +266,11 @@ class AngelBot(ClientXMPP):
         if msg["type"] in ("chat", "normal"):
             mtype = "chat"
             sender = msg["from"].bare
-            message = msg["body"]
 
-            ctx = message.strip().split()
+            edit = "urn:xmpp:message-correct:0" in str(msg)
+            if edit:
+                return
+
             try:
                 if not msg["oob"]["url"]:
                     if urls := self.get_urls(msg):
@@ -299,14 +278,7 @@ class AngelBot(ClientXMPP):
             except Exception:
                 pass
 
-            edit = "urn:xmpp:message-correct:0" in str(msg)
-
-            cm = ctx.pop(0)
-            if cm in self.commands:
-                if not edit:
-                    self.commands[cm](msg, ctx, sender)
-            else:
-                self.s(msg, sender, mtype)
+            self.s(msg, sender, mtype)
 
     async def muc_message(self, msg):
         if msg["type"] in ("groupchat", "normal"):
@@ -330,30 +302,6 @@ class AngelBot(ClientXMPP):
             else:
                 self.s(msg, sender, mtype)
 
-        @self.muc_word
-        def ping(msg, ctx, sender):
-            if ctx:
-                return
-            bot.send_message(
-                mto=sender, mbody=f"pong: {msg['mucnick']}", mtype="groupchat"
-            )
-
-            @self.word
-            def ping(msg, ctx, sender):
-                if ctx:
-                    return
-                bot.send_message(
-                    mto=sender,
-                    mbody=f"pong: {msg.get_from().bare}",
-                    mtype="chat",
-                )
-
-            @self.command
-            def join(msg, ctx, sender):
-                if sender == bot.owner:
-                    for channel in ctx:
-                        bot.plugin["xep_0045"].join_muc(channel, bot.nick)
-
 
 if __name__ == "__main__":
     config = configparser.ConfigParser()