|
@@ -1,4 +1,3 @@
|
|
|
-from common import log
|
|
|
|
|
from commands.common import CommandHelpers as CH
|
|
from commands.common import CommandHelpers as CH
|
|
|
|
|
|
|
|
bold = "\x02"
|
|
bold = "\x02"
|
|
@@ -15,8 +14,8 @@ def do_command(self, connection, event):
|
|
|
cmdtype, trigger, command, replyto = CH.disect_command(self, event)
|
|
cmdtype, trigger, command, replyto = CH.disect_command(self, event)
|
|
|
if not command: # Do nothing if there is no command.
|
|
if not command: # Do nothing if there is no command.
|
|
|
return
|
|
return
|
|
|
- if not self.db.one("SELECT games FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
|
|
|
|
|
- return # Do noting if the games channel function is off.
|
|
|
|
|
|
|
+ if not self.db.one("SELECT games FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'") and not event.target == connection.get_nickname():
|
|
|
|
|
+ return # Do noting if the games channel function is off and it's a channel message.
|
|
|
|
|
|
|
|
if command == "cmd" or command == "commands":
|
|
if command == "cmd" or command == "commands":
|
|
|
if cmdtype == "help": #Display help text.
|
|
if cmdtype == "help": #Display help text.
|
|
@@ -37,6 +36,7 @@ def do_command(self, connection, event):
|
|
|
|
|
|
|
|
# Parse user input
|
|
# Parse user input
|
|
|
user = event.source.nick
|
|
user = event.source.nick
|
|
|
|
|
+ channel = None
|
|
|
if not connection.get_nickname() == event.target: # Channel message.
|
|
if not connection.get_nickname() == event.target: # Channel message.
|
|
|
channel = event.target
|
|
channel = event.target
|
|
|
if len(command.split()) == 1: # Command contains only !joins.
|
|
if len(command.split()) == 1: # Command contains only !joins.
|
|
@@ -60,6 +60,47 @@ def do_command(self, connection, event):
|
|
|
elif len(command.split()) < 5: # To many arguments
|
|
elif len(command.split()) < 5: # To many arguments
|
|
|
connection.privmsg(replyto, "To many arguments. For help type " + blue + self.helpchar + "joins" + reset + ".")
|
|
connection.privmsg(replyto, "To many arguments. For help type " + blue + self.helpchar + "joins" + reset + ".")
|
|
|
return
|
|
return
|
|
|
|
|
+
|
|
|
|
|
+ if channel: # User and channel.
|
|
|
|
|
+ if command.split()[0] == "joins":
|
|
|
|
|
+ userstat = str(sum(self.db.all("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
|
|
+ userchannelstat = str(self.db.one("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'"))
|
|
|
|
|
+ channelstat = str(sum(self.db.all("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
|
|
+ if userchannelstat == "None":
|
|
|
|
|
+ userchannelstat = "0"
|
|
|
|
|
+ if userstat == "0": # No user joins on record.
|
|
|
|
|
+ connection.action(replyto, "has no record of any joins for " + red + user + reset + ".")
|
|
|
|
|
+ else: # User joins on record.
|
|
|
|
|
+ connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + ". Of which " + green + userchannelstat + reset + " have been in " + red + channel + reset + ", that has " + green + channelstat + reset + " " + command.split()[0] + reset + " in total.")
|
|
|
|
|
+ elif command.split()[0] == "kicks":
|
|
|
|
|
+ try:
|
|
|
|
|
+ givenkicks, receivedkicks = self.db.one("SELECT given, received FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
|
|
+ except:
|
|
|
|
|
+ givenkicks = 0
|
|
|
|
|
+ receivedkicks = 0
|
|
|
|
|
+ if givenkicks == 0 and receivedkicks == 0: # No kicks on record.
|
|
|
|
|
+ connection.action(replyto, "has no record of any kicks for " + red + user + reset + ".")
|
|
|
|
|
+ else: # Kciks on record.
|
|
|
|
|
+ channelkicks = self.db.all("SELECT given FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "'")
|
|
|
|
|
+ connection.privmsg(replyto, red + user + reset + " has kicked " + green + str(givenkicks) + reset + " and been kicked " + green + str(receivedkicks) + reset + " times in " + red + channel + reset + ", where were " + green + str(sum(channelkicks)) + reset + " kicks in total.")
|
|
|
|
|
+ else: # Only user.
|
|
|
|
|
+ if command.split()[0] == "joins":
|
|
|
|
|
+ userstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
|
|
+ if userstat == "0": # No statistics on user.
|
|
|
|
|
+ connection.action(replyto, "has no record of any " + command.split()[0] + " for " + red + user + reset + ".")
|
|
|
|
|
+ else: # Got statistics on user.
|
|
|
|
|
+ connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + " in channels I monitor.")
|
|
|
|
|
+ elif command.split()[0] == "kicks":
|
|
|
|
|
+ userstat = self.db.all("SELECT given, received FROM kicks WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
|
|
+ kicksgiven = 0
|
|
|
|
|
+ kicksreceived = 0
|
|
|
|
|
+ for record in userstat:
|
|
|
|
|
+ kicksgiven += record[0]
|
|
|
|
|
+ kicksreceived += record[1]
|
|
|
|
|
+ if kicksgiven == 0 and kicksreceived == 0:
|
|
|
|
|
+ connection.action(replyto, red + user + reset + " has no record of any kicks for " + red + user + reset + " in " + red + channel + reset + ".")
|
|
|
|
|
+ else:
|
|
|
|
|
+ connection.privmsg(replyto, red + user + reset + " has given " + green + str(kicksgiven) + reset + " and received " + green + str(kicksreceived) + reset + " kicks")
|
|
|
# userstatfields = ()
|
|
# userstatfields = ()
|
|
|
# userchannelstatfields = ()
|
|
# userchannelstatfields = ()
|
|
|
# channelstatfields = ()
|
|
# channelstatfields = ()
|
|
@@ -71,54 +112,24 @@ def do_command(self, connection, event):
|
|
|
# channelstatparameters = ()
|
|
# channelstatparameters = ()
|
|
|
|
|
|
|
|
|
|
|
|
|
- try:
|
|
|
|
|
- if user and channel:
|
|
|
|
|
- if command.split()[0] == "joins":
|
|
|
|
|
- userstat = str(sum(self.db.all("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
|
|
- userchannelstat = str(self.db.one("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'"))
|
|
|
|
|
- channelstat = str(sum(self.db.all("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
|
|
- if userchannelstat == "None":
|
|
|
|
|
- userchannelstat = "0"
|
|
|
|
|
- connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + ". Of which " + green + userchannelstat + reset + " have been in " + red + channel + reset + ", that has " + green + channelstat + reset + " " + command.split()[0] + reset + " in total.")
|
|
|
|
|
- elif command.split()[0] == "kicks":
|
|
|
|
|
- try:
|
|
|
|
|
- givenkicks, receivedkicks = self.db.one("SELECT given, received FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
|
|
- except:
|
|
|
|
|
- givenkicks = 0
|
|
|
|
|
- receivedkicks = 0
|
|
|
|
|
- channelkicks = self.db.all("SELECT given FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "'")
|
|
|
|
|
- connection.privmsg(replyto, red + user + reset + " has kicked " + green + str(givenkicks) + reset + " and been kicked " + green + str(receivedkicks) + reset + " times in " + red + channel + reset + ", where were " + green + str(sum(channelkicks)) + reset + " kicks in total.")
|
|
|
|
|
- return
|
|
|
|
|
- except:
|
|
|
|
|
- pass
|
|
|
|
|
- try:
|
|
|
|
|
- if user:
|
|
|
|
|
- if command.split()[0] == "joins":
|
|
|
|
|
- userstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
|
|
- if userstat == "[]":
|
|
|
|
|
- userstat = "[0]"
|
|
|
|
|
- connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + " in channels I monitor.")
|
|
|
|
|
- elif command.split()[0] == "kicks":
|
|
|
|
|
- userstat = self.db.all("SELECT given, received FROM kicks WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
|
|
- kicksgiven = 0
|
|
|
|
|
- kicksreceived = 0
|
|
|
|
|
- for record in userstat:
|
|
|
|
|
- kicksgiven += record[0]
|
|
|
|
|
- kicksreceived += record[1]
|
|
|
|
|
- print(record)
|
|
|
|
|
- print(userstat)
|
|
|
|
|
- connection.privmsg(replyto, red + user + reset + " has given " + green + str(kicksgiven) + reset + " and received " + green + str(kicksreceived) + reset + " kicks")
|
|
|
|
|
- return
|
|
|
|
|
- except:
|
|
|
|
|
- pass
|
|
|
|
|
- try:
|
|
|
|
|
- if channel: # This situation should not occur anymore.
|
|
|
|
|
- channelstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
|
|
- if command.split()[0] == "joins":
|
|
|
|
|
- connection.privmsg(replyto, red + channel + reset + " has been " + command.split()[0][:-1] + "ed " + green + channelstat + reset + " times.")
|
|
|
|
|
- elif command.split()[0] == "kicks":
|
|
|
|
|
- connection.privmsg(replyto, "There have been " + green + channelstat + reset + " kicks in " + red + command.split()[0] + reset + ".")
|
|
|
|
|
- return
|
|
|
|
|
- except:
|
|
|
|
|
- pass
|
|
|
|
|
- log.error("No situation applied on statistics.py")
|
|
|
|
|
|
|
+# try:
|
|
|
|
|
+# if user and channel:
|
|
|
|
|
+#
|
|
|
|
|
+# return
|
|
|
|
|
+# except:
|
|
|
|
|
+# pass
|
|
|
|
|
+# try:
|
|
|
|
|
+#
|
|
|
|
|
+# return
|
|
|
|
|
+# except:
|
|
|
|
|
+# pass
|
|
|
|
|
+# try:
|
|
|
|
|
+# if channel: # This situation should not occur anymore.
|
|
|
|
|
+# channelstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
|
|
+# if command.split()[0] == "joins":
|
|
|
|
|
+# connection.privmsg(replyto, red + channel + reset + " has been " + command.split()[0][:-1] + "ed " + green + channelstat + reset + " times.")
|
|
|
|
|
+# elif command.split()[0] == "kicks":
|
|
|
|
|
+# connection.privmsg(replyto, "There have been " + green + channelstat + reset + " kicks in " + red + command.split()[0] + reset + ".")
|
|
|
|
|
+# return
|
|
|
|
|
+# except:
|
|
|
|
|
+# pass
|