|
|
@@ -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.
|