| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import random
- bold = "\x02"
- italic = "\x1D"
- underline = "\x1F"
- reverse = "\x16" # swap background and foreground colors ("reverse video")
- reset = "\x0F"
- blue = "\x0302"
- green = "\x0303"
- red = "\x0304"
- grey = "\x0314"
- class CommandHelpers():
- def disect_command(self, event):
- trigger = event.arguments[0]
- command = trigger[1:] #Command without prefix.
-
- # Determine command type.
- if trigger.startswith(self.cmdchar):
- cmdtype = "cmd"
- elif trigger.startswith(self.helpchar):
- cmdtype = "help"
- else:
- cmdtype = False
-
- # Determine where to reply to.
- if event.type == "pubmsg":
- replyto = event.target
- elif event.type == "privmsg":
- replyto = event.source.nick
- else:
- replyto = False
-
- return(cmdtype, trigger, command, replyto)
-
- 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
- if rights["homechan"] == "admin":
- if self.channels[self.homechannel].is_owner(event.source.nick) or self.channels[self.homechannel].is_admin(event.source.nick):
- show = True
- if rights["homechan"] == "oper":
- if self.channels[self.homechannel].is_owner(event.source.nick) or self.channels[self.homechannel].is_admin(event.source.nick) or self.channels[self.homechannel].is_oper(event.source.nick):
- show = True
- if rights["chan"] == "owner":
- if self.channels[event.target].is_owner(event.source.nick):
- show = True
- if rights["chan"] == "admin":
- if self.channels[event.target].is_owner(event.source.nick) or self.channels[event.target].is_admin(event.source.nick):
- show = True
- if rights["chan"] == "oper":
- if self.channels[event.target].is_owner(event.source.nick) or self.channels[event.target].is_admin(event.source.nick) or self.channels[event.target].is_oper(event.source.nick):
- show = True
- if show:
- return blue + self.cmdchar + command + reset + ", "
- else:
- return blue + self.cmdchar + command + reset + ", "
-
- def get_channelfunctions(self, channel):
- channelfunctions = self.db.one("SELECT autojoin, aggressiveness, join_greeting, statistics_commands, games FROM channels WHERE LOWER(name)=LOWER('" + channel + "') AND network='" + self.network + "'")
- if channelfunctions[0]:
- autojoin = "on"
- else:
- autojoin = "off"
- if channelfunctions[2]:
- joingreet = "on"
- else:
- joingreet = "off"
- if channelfunctions[3]:
- statscmds = "on"
- else:
- statscmds = "off"
- if channelfunctions[4]:
- games = "on"
- else:
- games = "off"""
- return ("autojoin " + green + autojoin + reset + ", aggressiveness " + green + channelfunctions[1] + reset + ", join_greeting " + green + joingreet + reset + ", statistics_commands " + green + statscmds + reset + ", games " + green + games + reset + ".")
-
- def is_channelfunction(self, value):
- if value not in ["autojoin", "join_greeting", "statistics_commands", "games", "aggressiveness"]:
- return False
- else:
- return True
- class GameHelpers():
- def roll_dice(amount, type):
- rolls = []
- for iterations in range(amount):
- rolls.append(random.randint(1, type))
- return rolls
|