|
|
@@ -1,3 +1,4 @@
|
|
|
+from datetime import datetime
|
|
|
from commands.common import CommandHelpers as CH, StatisticsHelpers
|
|
|
|
|
|
bold = "\x02"
|
|
|
@@ -19,14 +20,14 @@ def do_command(self, connection, event):
|
|
|
|
|
|
if command == "cmd" or command == "commands":
|
|
|
if cmdtype == "cmd":
|
|
|
- connection.privmsg(replyto, grey + "Statistics commands: " + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages") + CH.ccc(self, "actions") + CH.ccc(self, "notices")[:-2] + ".")
|
|
|
+ connection.privmsg(replyto, grey + "Statistics commands: " + CH.ccc(self, "seen") + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages") + CH.ccc(self, "actions") + CH.ccc(self, "notices")[:-2] + ".")
|
|
|
|
|
|
|
|
|
elif command.split()[0] == "joins" or command.split()[0] == "kicks" or command.split()[0] == "messages" or command.split()[0] == "actions" or command.split()[0] == "notices":
|
|
|
if cmdtype == "help": #Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
|
return
|
|
|
- connection.privmsg(replyto, "Display amount of " + command.split()[0] + " of user and or channel. Channel and user optional.")
|
|
|
+ connection.privmsg(replyto, "Display amount of " + command.split()[0] + " of user and channel. Channel and user optional.")
|
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + self.cmdchar + command.split()[0] + " " + reset + italic + "channel user")
|
|
|
elif cmdtype == "cmd":
|
|
|
|
|
|
@@ -44,18 +45,18 @@ def do_command(self, connection, event):
|
|
|
if connection.get_nickname() == event.target: # Private message.
|
|
|
channelonly = True
|
|
|
else:
|
|
|
- user = command.split()[1]
|
|
|
+ user = trigger.split()[1]
|
|
|
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 + ".")
|
|
|
return
|
|
|
else: # User reverted user and channel in command syntax.
|
|
|
- user = command.split()[1]
|
|
|
+ user = trigger.split()[1]
|
|
|
channel = command.split()[2]
|
|
|
else: # Bot does inhabit requested channel.
|
|
|
- user = command.split()[2]
|
|
|
- channel = command.split()[1]
|
|
|
+ user = trigger.split()[2]
|
|
|
+ channel = trigger.split()[1]
|
|
|
elif len(command.split()) < 5: # To many arguments
|
|
|
connection.privmsg(replyto, "To many arguments. For help type " + blue + self.helpchar + "joins" + reset + ".")
|
|
|
return
|
|
|
@@ -127,3 +128,92 @@ def do_command(self, connection, event):
|
|
|
messages, words, characters = StatisticsHelpers.add_message_stats(chanstat)
|
|
|
message += " Total in " + red + channel + " " + green + str(messages) + reset + " " + blue + command.split()[0] + reset + ", " + green + str(words) + reset + " wrd, " + green + str(characters) + reset + " chr."
|
|
|
connection.privmsg(replyto, message)
|
|
|
+
|
|
|
+ elif command.split()[0] == "seen":
|
|
|
+ if cmdtype == "help": #Display help text.
|
|
|
+ if len(command.split()) is not 1:
|
|
|
+ return
|
|
|
+ connection.privmsg(replyto, "Report the last sighting of a user.")
|
|
|
+ connection.privmsg(replyto, grey + "Usage: " + blue + self.cmdchar + command.split()[0] + " " + reset + italic + "user")
|
|
|
+ elif cmdtype == "cmd":
|
|
|
+
|
|
|
+ if len(command.split()) == 1:
|
|
|
+ connection.privmsg(replyto, "I asm seeing you right now. For help type " + blue + self.helpchar + reset + ".")
|
|
|
+ elif len(command.split()) == 2:
|
|
|
+ if not self.db.one("SELECT last_act_type FROM users WHERE LOWER(name)='" + command.split()[1] + "' AND network='" + self.network + "'"):
|
|
|
+ print("SELECT last_act_type FROM users WHERE LOWER(name)='" + command.split()[1] + "' AND network='" + self.network + "'")
|
|
|
+ print(self.db.one("SELECT last_act_type FROM users WHERE LOWER(name)='" + command.split()[1] + "' AND network='" + self.network + "'"))
|
|
|
+ connection.action(replyto, "has never seen " + red + command.split()[1] + reset + ".")
|
|
|
+ else:
|
|
|
+ record = self.db.one("SELECT last_act_type, last_act_datetime, last_act_channel, last_act, last_act_auxiliary FROM users WHERE LOWER(name)='" + command.split()[1] + "' AND network='" + self.network + "'")
|
|
|
+ action = "last saw " + red + trigger.split()[1] + reset + " "
|
|
|
+ print(record)
|
|
|
+ if record[0] == "nick":
|
|
|
+ action += "changing nickname to " + red + record[3]
|
|
|
+ elif record[0] == "join":
|
|
|
+ action += "joining " + red + record[2]
|
|
|
+ elif record[0] == "kick":
|
|
|
+ if record[4]:
|
|
|
+ action += "kicking " + red + record[4] + reset + " for " + green + record[3]
|
|
|
+ else:
|
|
|
+ action += "kicking " + red + record[3]
|
|
|
+ elif record[0] == "kicked":
|
|
|
+ if record[4]:
|
|
|
+ action += "being kicked by " + red + record[3] + reset + " for " + green + record[4]
|
|
|
+ else:
|
|
|
+ action += "being kicked by " + red + record[3]
|
|
|
+ elif record[0] == "mode":
|
|
|
+ action += "changing modes on " + red + record[3]
|
|
|
+ elif record[0] == "part":
|
|
|
+ action += "parting " + red + record[2]
|
|
|
+ if record[3]:
|
|
|
+ action += reset + " for " + record[3]
|
|
|
+ elif record[0] == "quit":
|
|
|
+ action += "disconnecting"
|
|
|
+ if record[3]:
|
|
|
+ action += " due to " + green + record[3]
|
|
|
+ elif record[0] == "topic":
|
|
|
+ action += "changing the topic of " + red + record[2] + reset + " to " + green + record[3]
|
|
|
+ elif record[0] == "msg":
|
|
|
+ action += "posting " + green + record[3] + reset + " to " + red + record[2]
|
|
|
+ elif record[0] == "notice":
|
|
|
+ action += "posting the notice " + green + record[3] + " to " + red + record[2]
|
|
|
+ elif record[0] == "action":
|
|
|
+ action += green + record[3] + reset + " in " + red + record[2]
|
|
|
+ else:
|
|
|
+ connection.privmsg(replyto, "Last stored action unsupported by command code.")
|
|
|
+ return
|
|
|
+ action += reset + ", "
|
|
|
+ print(datetime.now() - record[1])
|
|
|
+ differential = datetime.now() - record[1]
|
|
|
+ if differential.seconds < 5: # Less then 5 seconds.
|
|
|
+ action += blue + "right now."
|
|
|
+ elif differential.seconds < 20: # Less then 20 seconds.
|
|
|
+ action += blue + "just now."
|
|
|
+ elif differential.seconds < 60: # Less then a minute.
|
|
|
+ action += green + str(differential.seconds) + blue + " seconds " + reset + "ago."
|
|
|
+ elif differential.seconds == 60: # 1 minute.
|
|
|
+ action += green + "1 " + blue + "minute " + reset + "ago."
|
|
|
+ elif int(differential.seconds / 60) < 60: # Less then an hour.
|
|
|
+ action += green + str(int(differential.seconds / 60)) + " minutes " + reset + "ago."
|
|
|
+ elif int(differential.seconds / 60) == 60: # 1 hour.
|
|
|
+ action += green + "1 " + blue + "hour " + reset + "ago."
|
|
|
+ elif int(differential.seconds / 3600) < 24 : # Less then a day.
|
|
|
+ remaining_seconds = int(differential.seconds - int(differential.seconds / 3600) * 3600)
|
|
|
+ action += green + str(int(differential.seconds / 3600)) + blue + " hours" + reset + " and " + str(int(remaining_seconds / 60)) + " minutes ago."
|
|
|
+ elif int(differential.seconds / 3600) == 24 : # 1 day.
|
|
|
+ action += green + "1 " + blue + "day " + reset + "ago."
|
|
|
+ elif differential.days < 7: # Less then a week.
|
|
|
+ remaining = differential - datetime.timedelta(days=differential.days)
|
|
|
+ action += green + str(differential.days) + blue + " days " + reset + "and " + str(int(remaining.seconds / 3600)) + " hours ago."
|
|
|
+ elif differential.days < 365: # Less then a year.
|
|
|
+ action += green + str(differential.days) + blue + " days " + reset + "ago."
|
|
|
+ elif differential.days < 365: # Less then 5 years.
|
|
|
+ remaining_days = int(int(differential.days / 365) * 365)
|
|
|
+ remaining = differential - datetime.timedelta(days=remaining_days)
|
|
|
+ action += green + str(int(differential.days / 365)) + blue + " years " + reset + "and " + str(remaining.days) + " days."
|
|
|
+ else: # More then 5 years.
|
|
|
+ action += green + str(int(differential.days / 365)) + blue + " years ago."
|
|
|
+ connection.action(replyto, action)
|
|
|
+ else: # Too many arguments.
|
|
|
+ connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "seen" + reset + ".")
|