tBKwtWS 7 years ago
parent
commit
07b3075a71

BIN
commands/__pycache__/admin.cpython-36.pyc


BIN
commands/__pycache__/common.cpython-36.pyc


BIN
commands/__pycache__/public.cpython-36.pyc


+ 12 - 9
commands/admin.py

@@ -20,15 +20,18 @@ def do_command(self, connection, event):
     
     if command == "cmd" or command == "commands":
         if cmdtype == "cmd":
-            connection.privmsg(replyto, grey + "Admin: "
-           + CH.ccc(self, "channelfunctions",  {"homechan": "oper", "chan": "oper"}, event)
-           + CH.ccc(self, "join", {"homechan": "oper",  "chan": None}, event)
-           + CH.ccc(self, "part", {"homechan": "oper",  "chan": None}, event)
-           + CH.ccc(self, "die",  {"homechan": "admin",  "chan": None}, event)
-           + CH.ccc(self, "reconnect", {"homechan": "oper",  "chan": None}, event)
-           + CH.ccc(self, "recovernick",  {"homechan": "oper",  "chan": None}, event)
-           + CH.ccc(self, "msg",  {"homechan": "oper",  "chan": "oper"}, event)
-           + CH.ccc(self, "act", {"homechan": "oper",  "chan": "oper"}, event)[:-2] + ".")
+            message = str(
+                grey + "Admin: "
+                + CH.ccc(self, "channelfunctions",  {"homechan": "oper", "chan": "oper"}, event)
+                + CH.ccc(self, "join", {"homechan": "oper",  "chan": None}, event)
+                + CH.ccc(self, "part", {"homechan": "oper",  "chan": None}, event)
+                + CH.ccc(self, "die",  {"homechan": "admin",  "chan": None}, event)
+                + CH.ccc(self, "reconnect", {"homechan": "oper",  "chan": None}, event)
+                + CH.ccc(self, "recovernick",  {"homechan": "oper",  "chan": None}, event)
+                + CH.ccc(self, "msg",  {"homechan": "oper",  "chan": "oper"}, event)
+                + CH.ccc(self, "act", {"homechan": "oper",  "chan": "oper"}, event)
+            )
+            connection.privmsg(replyto, message[:-2] + ".")
     
     elif command.split()[0] == "channelfunctions":
         if cmdtype == "help":    #Display help text. # Help code block first, as it is impossible to predict for what channel a later command is going to be issued. Rights filtering after help test.

+ 1 - 0
commands/common.py

@@ -34,6 +34,7 @@ class CommandHelpers():
     
     def ccc(self, command, rights=False, event=False):   # Commandlist colour coding and channel rights filter.
         if rights:
+            show = False
             if rights["homechan"] == "owner":
                 if self.channels[self.homechannel].is_owner(event.source.nick):
                     show = True

+ 18 - 17
commands/public.py

@@ -56,16 +56,16 @@ def do_command(self, connection, event):
         elif cmdtype == "cmd":
             
             # Parse user input
-            if len(command.split()) < 2:    # Command contains only !joins.
+            if len(command.split()) == 1:    # Command contains only !joins.
                 user = event.source.nick
-                if connection.get_nickname() is not event.target:
+                if connection.get_nickname() is not event.target:   # Channel message.
                     channel = event.target
-            elif len(command.split()) < 3:  # Command has one argument.
+            elif len(command.split()) == 2:  # Command has one argument.
                 if command.split()[1] in self.channels:
                     channel = command.split()[1]
                 else:
                     user = command.split()[1]
-            elif len(command.split()) < 4: # Command has two arguments.
+            elif len(command.split()) == 3: # Command has two arguments.
                 if not command.split()[1] in self.channels: # Bot does not inhabit requested channel.
                     if not command.split()[2] in self.channels: # User did not revert channel and user in command syntax.
                         connection.action(replyto, "does not inhabit " + red + command.split()[1] + reset + ".")
@@ -79,19 +79,20 @@ def do_command(self, connection, event):
             elif len(command.split()) < 5:  # To many arguments
                 connection.privmsg(replyto, "To many arguments. For help type " + blue + self.helpchar + "joins" + reset + ".")
                 return
-            try: 
+            
+            try:
                 if user and channel:
-                    userjoins = str(self.db.one("SELECT joins FROM joins WHERE channel_network='" + self.network + "' AND \"user\"='" + user + "' AND user_network='" + self.network + "'"))
+                    userjoins = str(self.db.all("SELECT joins FROM joins WHERE channel_network='" + self.network + "' AND \"user\"='" + user + "' AND user_network='" + self.network + "'"))
                     userchanneljoins = str(self.db.one("SELECT joins FROM joins WHERE channel='" + channel + "' AND channel_network='" + self.network + "' AND \"user\"='" + user + "' AND user_network='" + self.network + "'"))
                     channeljoins = str(sum(self.db.all("SELECT joins FROM joins WHERE channel='" + channel + "' AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
-                    connection.privmsg(replyto, red + user + reset + " has " + green + userjoins + reset + " joins. Of which " + green + userchanneljoins + reset + " have been in " + red + channel + reset + ", that has " + green + channeljoins + reset + " joins" + reset + " in total.")
+                    connection.privmsg(replyto, red + user + reset + " has " + green + str(sum(list(map(int, userjoins[1:-1].split(", "))))) + reset + " joins. Of which " + green + str(userchanneljoins) + reset + " have been in " + red + channel + reset + ", that has " + green + str(channeljoins) + reset + " joins" + reset + " in total.")
                     return
             except:
                 pass
             try:
                 if user:
-                    userjoins = str(self.db.one("SELECT joins FROM joins WHERE channel='" + event.target + "' AND channel_network='" + self.network + "' AND \"user\"='" + event.source.nick + "' AND user_network='" + self.network + "'"))
-                    connection.privmsg(replyto,  red + user + reset + " has " + green + userjoins + reset + " joins in channels I monitor.")
+                    userjoins = str(self.db.all("SELECT joins FROM joins WHERE channel_network='" + self.network + "' AND \"user\"='" + user + "' AND user_network='" + self.network + "' AND user_network='" + self.network + "'"))
+                    connection.privmsg(replyto,  red + user + reset + " has " + green + str(sum(list(map(int, userjoins[1:-1].split(", "))))) + reset + " joins in channels I monitor.")
                     return
             except:
                 pass
@@ -109,16 +110,9 @@ def do_command(self, connection, event):
             if len(command.split()) is not 1:
                 return
             connection.privmsg(replyto, "Stops the bot from greeting you or a specific user. Channel, user and option to resume optional.")
-            connection.privmsg(replyto, grey + "Usage: " + blue + "!stopgreet " + red + italic + "resume channel user")
+            connection.privmsg(replyto, grey + "Usage: " + blue + "!stopgreet " + red + reset + italic + "resume " + red + "channel user")
         elif cmdtype == "cmd":
             
-            if len(command.split()) == 1:    # No arguments.
-                if event.target == connection.get_nickname():   # PM.
-                    connection.privmsg(replyto, "Specify at least a channel. For help type " + blue + self.helpchar + "stopgreet" + reset + ".")
-                    return
-                user = event.source.nick
-                channel = event.target
-            
             # Check for resume variation of command.
             resume = False
             try:
@@ -127,6 +121,13 @@ def do_command(self, connection, event):
                     command = command.split(' ', 1)[1]  # Remove the resume argument. Which makes the following logic easier.
             except:
                 pass
+            
+            if len(command.split()) == 1:    # No arguments.
+                if event.target == connection.get_nickname():   # PM.
+                    connection.privmsg(replyto, "Specify at least a channel. For help type " + blue + self.helpchar + "stopgreet" + reset + ".")
+                    return
+                user = event.source.nick
+                channel = event.target
                 
             if len(command.split()) == 2:    # One argument.
                 if command.split()[1] not in self.channels: # Argument is not a channel the bot inhabits.

BIN
events/__pycache__/on_join.cpython-36.pyc


+ 10 - 1
events/on_join.py

@@ -20,7 +20,16 @@ def process_event(self, connection, event):
     
     if event.source.nick == connection.get_nickname():  # The bot joined a channel.
         return
-    # If channelsettings permit show welcome message.
+    
+    # Stop if greeting is not wanted.
+    joingreeting = self.db.one("SELECT join_greeting FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'")
+    stopgreet = self.db.one("SELECT stopgreet FROM joins WHERE channel='" + event.target + "' AND channel_network='" + self.network + "' AND \"user\"='" + event.source.nick + "' AND user_network='" + self.network + "'")
+    print(joingreeting)
+    print(stopgreet)
+    if not joingreeting or stopgreet:
+        return
+    
+    # Show greeting.
     joins = self.db.one("SELECT joins FROM joins WHERE channel='" + event.target + "' AND channel_network='" + self.network + "' AND \"user\"='" + event.source.nick + "' AND user_network='" + self.network + "'")
     if not self.db.one("SELECT join_greeting FROM channels WHERE name='" + event.target + "' AND network ='" + self.network + "'"): # Do not greet users joining the channel.
         return