| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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, join_greeting, statistics_commands, games FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'")
- if channelfunctions[0]:
- autojoin = "on"
- else:
- autojoin = "off"
- if channelfunctions[1]:
- joingreet = "on"
- else:
- joingreet = "off"
- if channelfunctions[2]:
- statscmds = "on"
- else:
- statscmds = "off"
- if channelfunctions[3]:
- games = "on"
- else:
- games = "off"
- return ("autojoin " + autojoin + ", join_greeting " + joingreet + ", statistics_commands " + statscmds + ", games " + games + ".")
-
- def is_channelfunction(self, value):
- if value not in ["autojoin", "join_greeting", "statistics_commands", "games"]:
- 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
-
|