def __init__(self): """ Costruttore """ self.pattern = [] self.stats = {} self.pattern_stats = [0, (0, 0)] self.debug = False self.label = "Mp3 filter" self.load_config() for evnt in filter_event: xchat.hook_print(evnt, self.ignore_mp3_notification) xchat.hook_command("mp3filter_reload", self.reload_config, help="Carica nuovamente i filtri dalla config") xchat.hook_command("mp3filter_stats", self.pattern_status, help="Statistiche sui filtri usati") xchat.hook_command("mp3filter_debug", self.debug_swap, help="Stampa i messaggi che vengono \ bloccati; Utile per capire \ quali messaggi bloccano gli attuali filtri") xchat.command('MENU ADD "%s"' % self.label) xchat.command('MENU ADD "%s/Ricarica filtri" "mp3filter_reload"' % self.label) xchat.command('MENU ADD "%s/Statistiche filtri" "mp3filter_stats"' % self.label) xchat.command('MENU ADD "%s/Debug" "mp3filter_debug None"' % self.label) print "Filtro mp3 caricato su: \x0304%s\x03" % ', '.join(filter_event) s=self.pattern_stats print "%d/%d filtri caricati!" % (s[1][0], s[0])
def toggle_cb(self, word, word_eol, userdata): if len(word) < 2 or word[1].lower() not in ['on', 'off', 'status']: self.notice("Please provide a command: 'on', 'off', or 'status'") return xchat.EAT_ALL command = word[1].lower() if command == "on": if self.hooks: self.notice("Hush is already on") return xchat.EAT_ALL for event in ["Join", "Part", "Part with Reason", "Quit", "Change Nick"]: self.hooks.append(xchat.hook_print(event, self.selective_hush_cb)) for event in ["Private Message", "Private Action", "Channel Message", "Channel Action"]: self.hooks.append(xchat.hook_print(event, self.record_cb)) self.hooks.append(xchat.hook_timer(5 * 60 * 1000, self.reaper_cb)) self.notice("Loaded Hush") return xchat.EAT_ALL elif command == "off": if self.hooks: map(xchat.unhook, self.hooks) self.hooks = [] self.active_users = [] self.notice("Unloaded Hush") else: self.notice("Hush is already off") return xchat.EAT_ALL elif command == "status": status = {True: "on", False: "off"} self.notice("Hush is %s" % status[bool(self.hooks)]) return xchat.EAT_ALL
def WhoStoleIt(userdata): global dInfo sServ=xchat.get_info("network") if sServ in dInfo: xchat.command("whois %s" % dInfo[sServ]["nick"]) dInfo[sServ]["who1"] = xchat.hook_print("Generic Message", Test) dInfo[sServ]["who2"] = xchat.hook_print("WhoIs End", WhoEnd)
def __init__(self): # self._server_charset = {} self.fallbacks = ['cp1255'] # that will be configurable and user-settable. self._ignore_receive = False self._ignore_send = False for event in EVENTS: xchat.hook_print(event[0], self.convert, event, priority=xchat.PRI_HIGHEST) # xchat.hook_command('', self.debug_print, 'all', priority=xchat.PRI_HIGHEST) xchat.hook_command('', self.fix_sends, priority=xchat.PRI_HIGHEST) for cmd in ('SAY', 'ME', 'MSG'): xchat.hook_command(cmd, self.fix_sendcmd, cmd, priority=xchat.PRI_HIGHEST)
def xchatHook(self): print 'rehooking' if not len(self.hooked): self.hooked = [xchat.hook_print('Channel Message', alerts.general_message, userdata=None, priority=xchat.PRI_NORM), xchat.hook_print('Channel Msg Hilight', alerts.general_message, userdata=None, priority=xchat.PRI_NORM), xchat.hook_print('Private Message', alerts.private_message, userdata=None, priority=xchat.PRI_NORM), xchat.hook_print('Private Message to Dialog', alerts.private_message, userdata=None, priority=xchat.PRI_NORM)]
def __init__(self) : self.start_time = time.time() for event in XchatSoundHandler.EVENTS : xchat.hook_print(event, self.handle_message, event) xchat.hook_command("chatsounds", self.handle_prefs) xchat.hook_command("cs", self.handle_prefs) self.player = SoundPlayer() self.sound_dir = os.path.expanduser("~/.xchat2/sounds/") self.silenced_channels = SILENCED_CHANNELS debugprint("Loaded chatsounds.py")
def __init__(self): self.start_time = time.time() for event in XchatSoundHandler.EVENTS: xchat.hook_print(event, self.handle_message, event) xchat.hook_command("chatsounds", self.handle_prefs) xchat.hook_command("cs", self.handle_prefs) self.player = SoundPlayer() self.sound_dir = os.path.expanduser("~/.xchat2/sounds/") self.silenced_channels = [] print "Loaded chatsounds.py"
def __init__(self): self._enabled = {} for action in ( 'Channel Action', 'Channel Action Hilight', 'Channel Message', 'Channel Msg Hilight', ): xchat.hook_print(action, self.message, action) xchat.hook_command('audio', self._cmd, help=self.cmd_help()) xchat.hook_unload(self.kill) self.p = None self.voice = 'en-us' self.speed = 170 self.pitch = 50
def init(ignore_data=None): hooks.append(xchat.hook_timer(500, numerator.update_timer_cb)) hooks.append(xchat.hook_print("Focus Tab", numerator.reset_activity_cb)) for evt in ('Channel Action Hilight', 'Channel Msg Hilight', 'Channel Message', 'Private Message to Dialog', 'Private Action to Dialog'): hooks.append(xchat.hook_print(evt, numerator.activity_cb)) try: numerator.enumerate_tabs() except WindowsError as e: numerator.log("error on initial enumeration") numerator.log("successfully loaded") return 0 # do not repeat timer
def skip_print(self, name): def hook_func(word, word_eol, userdata): return xchat.EAT_XCHAT hook = xchat.hook_print(name, hook_func, priority=xchat.PRI_HIGHEST) yield xchat.unhook(hook)
def is_msg_color(word, word_eol, userdata): global color_hook if color_hook == "OFF": color_hook = xchat.hook_print("Key Press", msg_color) print("coloring") return xchat.EAT_ALL return xchat.EAT_ALL
def steinertoggle(userdata): global steinerhook print("Enabling Steiner function") if steinerhook is None: steinerhook = xchat.hook_print("Channel Message", steiner) else: steinerhook = None
def __init__(self): self.id_dh = {} self.hooks = [ xchat.hook_command('', self.on_send_message), xchat.hook_command('ME', self.on_send_me), xchat.hook_command('MSG', self.on_send_msg), xchat.hook_command('NOTICE', self.on_send_notice), xchat.hook_server('notice', self.on_recv_notice, priority=xchat.PRI_HIGHEST), xchat.hook_print('Change Nick', self.on_change_nick), xchat.hook_unload(self.unload), ] for name in ( 'Channel Action', 'Private Action to Dialog', 'Private Action', 'Channel Message', 'Private Message to Dialog', 'Private Message' ): xchat.hook_print(name, self.on_recv_message, name, priority=xchat.PRI_HIGHEST),
def setup(): try: cmd = __module_name__.upper() xchat.hook_command(cmd, getLocationCB, help="""/{} [<userid>] Gets location of user(s). When used in a channel, list location for all users in the channel. Otherwise, print the location of the given user <userid>.""". format(cmd)) xchat.hook_print("Join", getLocationJoinCB) xchat.hook_print("Whois Name Line", getLocationWhoisNameCB) xchat.hook_unload(unloadCB) print colordecode("%C4Plugin %B" + __module_name__ + "%B " + __module_version__ + " loaded.") except: print "can't hook callbacks to xchat"
def join_flood_en(word, word_eol, userdata): global join_flood_hook global join_flood_e if join_flood_e == -1: join_flood_e = 0 join_flood_hook = xchat.hook_print("You Join", join_flood) print("Join flood enabled") return xchat.EAT_ALL
def check_process(self, word, word_eol, userdata): self.checkchannel = word[1] self.hostlist = [] self.kicklist = [] xchat.hook_print("Join", self.onJoin) xchat.hook_print("Quit", self.onQuit) xchat.hook_print("Part", self.onPart) xchat.hook_print("Kick", self.onKick) xchat.hook_print("Part with Reason", self.onPartReason) self.IRCserver = xchat.get_info("server") self.cnc = xchat.find_context(channel = self.checkchannel, server= self.IRCserver) userlist = self.cnc.get_list("users") for i in userlist: if i.host not in self.hostlist: self.hostlist.append(i.host) elif i.host in self.hostlist: self.cnc.prnt("\0034\007\002CLONE DETECTED = %s" % i.host) #print(self.hostlist) #DEBUG print("Script ready")
def init(ignore_data=None): hooks.append(xchat.hook_timer(500, numerator.update_timer_cb)) hooks.append(xchat.hook_print("Focus Tab", numerator.reset_activity_cb)) for evt in ('Channel Action Hilight' ,'Channel Msg Hilight' ,'Channel Message' ,'Private Message to Dialog' ,'Private Action to Dialog'): hooks.append(xchat.hook_print(evt, numerator.activity_cb)) try: numerator.enumerate_tabs() except WindowsError as e: numerator.log("error on initial enumeration") numerator.log("successfully loaded") return 0 # do not repeat timer
def __init__(self): self.id_dh = {} self.hooks = [ xchat.hook_command('', self.on_send_message), xchat.hook_command('ME', self.on_send_me), xchat.hook_command('MSG', self.on_send_msg), xchat.hook_command('NOTICE', self.on_send_notice), xchat.hook_server('notice', self.on_recv_notice, priority=xchat.PRI_HIGHEST), xchat.hook_print('Change Nick', self.on_change_nick), xchat.hook_unload(self.unload), ] for name in ('Channel Action', 'Private Action to Dialog', 'Private Action', 'Channel Message', 'Private Message to Dialog', 'Private Message'): xchat.hook_print(name, self.on_recv_message, name, priority=xchat.PRI_HIGHEST),
def xchatHook(self): print 'rehooking' if not len(self.hooked): self.hooked = [ xchat.hook_print('Channel Message', alerts.general_message, userdata=None, priority=xchat.PRI_NORM), xchat.hook_print('Channel Msg Hilight', alerts.general_message, userdata=None, priority=xchat.PRI_NORM), xchat.hook_print('Private Message', alerts.private_message, userdata=None, priority=xchat.PRI_NORM), xchat.hook_print('Private Message to Dialog', alerts.private_message, userdata=None, priority=xchat.PRI_NORM) ]
def toggle_cb(self, word, word_eol, userdata): if len(word) < 2 or word[1].lower() not in ['on', 'off', 'status']: self.notice("Please provide a command: 'on', 'off', or 'status'") return xchat.EAT_ALL command = word[1].lower() if command == "on": if self.hooks: self.notice("Hush is already on") return xchat.EAT_ALL for event in [ "Join", "Part", "Part with Reason", "Quit", "Change Nick" ]: self.hooks.append( xchat.hook_print(event, self.selective_hush_cb)) for event in [ "Private Message", "Private Action", "Channel Message", "Channel Action" ]: self.hooks.append(xchat.hook_print(event, self.record_cb)) self.hooks.append(xchat.hook_timer(5 * 60 * 1000, self.reaper_cb)) self.notice("Loaded Hush") return xchat.EAT_ALL elif command == "off": if self.hooks: map(xchat.unhook, self.hooks) self.hooks = [] self.active_users = [] self.notice("Unloaded Hush") else: self.notice("Hush is already off") return xchat.EAT_ALL elif command == "status": status = {True: "on", False: "off"} self.notice("Hush is %s" % status[bool(self.hooks)]) return xchat.EAT_ALL
def __init__(self): #Decode hooks xchat.hook_print("Private Message", self.decode, "Private Message") xchat.hook_print("Private Message to Dialog", self.decode, "Private Message to Dialog") xchat.hook_print("Quit", self.quithook, "Quit") xchat.hook_print("Connected", self.resetconversationshook, "Connected") xchat.hook_print("Your Nick Changing", self.resetconversationshook, "Your Nick Changing") #Generic encode hook self.allhook = xchat.hook_command("", self.encode) #TODO RandomPool is know to be broken #Random generator self.randfunc = get_random_bytes #Initialize configuration directory confDir = xchat.get_info("xchatdirfs") + "/cryptochati.conf" if not os.path.isdir(confDir): os.makedirs(confDir, 0700) #Friends file self.friendsPath = os.path.join(confDir, "friends.txt") #Private key file self.myKeyPath = os.path.join(confDir, "my.key") #Friends' public keys file self.keysPath = os.path.join(confDir, "public.keys") #Create/load configuration self.openConfiguration() #Friend management hook xchat.hook_command("Friend", self.friendhook, "Friend", help= """Usage: FRIEND ADD <nick> - adds <nick> as a trusted friend FRIEND DEL <nick> - deletes <nick> from trusted friends FRIEND LIST - lists current trusted friends""")
def on_join(word, word_eol, userdata): # use global variable for unhooking global rename_hook # for comfort instead of word[0], word[1] and word[2] triggernick, triggerchannel, triggerhost = word # get the context destination = xchat.get_context() # if the channel is bitlbees channel and the nick begins with a dash if ((triggerchannel == "&bitlbee") and ((triggernick[0] == "-") or (triggernick[0] == "_"))): # send a whois on the nick xchat.command("whois %s" % triggernick) # make a handler that hooks the Name Line of the whois and calls rename_name with this line rename_hook = xchat.hook_print("Whois Name Line", rename_name) # unhook the whois return
def setup(self): # Register contact events raised by minbif. xchat.hook_print('Channel DeVoice', self.replicate_event, (1, 'is away')) xchat.hook_print('Channel Voice', self.replicate_event, (1, 'is back')) xchat.hook_print('Join', self.replicate_event, (0, 'has joined')) # The following is already notified. #xchat.hook_print('Quit', self.replicate_event, (0, 'has quit')) xchat.hook_unload(self.unload_cb) xchat.prnt('%s version %s by %s loaded' % ( __module_name__, __module_version__, __author__))
def setup(self): # Register contact events raised by minbif. xchat.hook_print('Channel DeVoice', self.replicate_event, (1, 'is away')) xchat.hook_print('Channel Voice', self.replicate_event, (1, 'is back')) xchat.hook_print('Join', self.replicate_event, (0, 'has joined')) # The following is already notified. #xchat.hook_print('Quit', self.replicate_event, (0, 'has quit')) xchat.hook_unload(self.unload_cb) xchat.prnt('%s version %s by %s loaded' % (__module_name__, __module_version__, __author__))
def load(*args): groups_load_from_settings() compile_strings() for event in chat_events: xchat.hook_print(event, dispatch_message, event) xchat.hook_print("Key Press", dispatch_key) xchat.hook_command("", dispatch_command) xchat.hook_command("ov", command_handler) for event in ["You Join", "You Kicked", "You Part", "you Part with Reason"]: xchat.hook_print(event, dispatch_channels_change, event) print(__module_name__, __module_version__, 'loaded')
def enable(self): self.is_enabled = True #read in config self.config = ConfigParser.RawConfigParser() self.config.read('config.conf') #set menus self.setup_nick_menu() #create list of channels try: for channel in xchat.get_list("channel"): dir(channel) except KeyError: pass #watch for new channels joined xchat.hook_command("join", self.on_channel_join) #watch for channels left xchat.hook_command("part", self.on_channel_part) #set hooks for joti/join/part/messages xchat.hook_command("joti", self.dispatch) xchat.hook_print('Channel Message', self.on_text) xchat.hook_print('Join', self.on_join) xchat.hook_print('Part', self.on_part)
destination = xchat.get_context() channel = destination.get_info('channel').lower() network = destination.get_info('network').lower() for relaypair in option["relaypairs"]: if relaypair[0] == network and relaypair[1] == channel: destination = xchat.find_context(server=relaypair[2], channel=relaypair[3]) destination.command("say " + "<" + triggernick + "> was deoped by " + operator + " in " + channel + " on " + network) load_vars() #The hooks go here xchat.hook_print('Channel Message', on_text) xchat.hook_print('Join', on_join) xchat.hook_print('Part', on_part) xchat.hook_print('Channel Voice', on_voice) xchat.hook_print('Channel DeVoice', on_devoice) xchat.hook_print('Kick', on_kick) xchat.hook_print('Channel Ban', on_ban) xchat.hook_print('Channel UnBan', on_unban) xchat.hook_print('Channel Operator', on_op) xchat.hook_print('Channel DeOp', on_deop) xchat.hook_command( 'relaybot', on_local, help= "Commands are /relaybot add list delete off on, see readme for full help") # Todo: Maybe later we add relaying joins, parts, bans, etc, no maybe not
cmd_aliases = {'highlights': {'xhighlights': {'helpfix': ('XHIGH', 'HIGH')}, }, } # Fix help and descriptions for aliases for aliasname in cmd_aliases.keys(): # Fix help for cmd in cmd_aliases[aliasname]: replacestr, replacewith = cmd_aliases[aliasname][cmd]['helpfix'] cmd_help[aliasname] = cmd_help[cmd].replace(replacestr, replacewith) # Fix description aliasforcmds = list(cmd_aliases[aliasname].keys()) aliasfor = aliasforcmds[0] commands[aliasname]['desc'] = commands[aliasfor]['desc'] # Hook all enabled commands. for cmdname in commands.keys(): if commands[cmdname]['enabled']: xchat.hook_command(cmdname.upper(), commands[cmdname]['func'], userdata=None, help=cmd_help[cmdname]) # Hook into channel msgs for eventname in ('Channel Message', 'Channel Msg Hilight', 'Your Message'): xchat.hook_print(eventname, message_filter, userdata=eventname) # Print status print('{} loaded.'.format(color_text('blue', VERSIONSTR)))
return xchat.EAT_NONE command = word[1].split(' ')[0].lower() if command == "!since": #Command not particularly useful if stream is live if monitoring["monotonetim"][0] is Status.online: xchat.command("say MonotoneTim is live right now!") timer = xchat.hook_timer(60000, cooldown_cb) cooldown = True return xchat.EAT_NONE if lastStreamTime == -1: file = open(filename, "r") lastStreamTime = float(file.read()) file.close() delta = TimeDelta(time.time() - lastStreamTime) xchat.command("say " + delta.readableTime()) timer = xchat.hook_timer(60000, cooldown_cb) cooldown = True return xchat.EAT_NONE def cooldown_cb(userdata): global cooldown #There should only be one cooldown in this script, #as the other script covers cooldown commands cooldown = False return 0 xchat.hook_print("Channel Message", since_cb) xchat.hook_command("monitor", monitor_cb, help = "/MONITOR Alerts when Tim is live") xchat.hook_command("unmonitor", unmonitor_cb, help = "/UNMONITOR Stop monitoring")
global CommandQueue, Active botname = str(split[2]) for cmd in (c for c in Active if c.bot == botname): print_error("Requested file \"%s\" has stalled during transport." % (split[1])) ret = cmd.retry() if ret: print_info("Re-requesting file \"%s\" (%d of 3 retries)" % (split[1], Active.retries)) else: print_error("Retry limit reached for file \"%s\". Stopping the queue." % (split[1])) __unhook__ = xchat.hook_command("xdccq", dispatch, help=USAGE_STR) print_info("XdccQ-TNG loaded successfully") usage() noticeHook = xchat.hook_print("Notice", notice, "data") dccRecvCompleteHook = xchat.hook_print("DCC RECV Complete", dccComplete, "data") dccRecvConnectHook = xchat.hook_print("DCC RECV Connect", dccConnect, "data") dccRecvStallHook = xchat.hook_print("DCC Stall", dccStall, "data") if __name__ == "__main__": def tests(): """ >>> numToList("1") [1] >>> numToList("1,2,4") [1, 2, 4] >>> numToList("1-4") [1, 2, 3, 4] >>> numToList("1-4,8,12") [1, 2, 3, 4, 8, 12]
if not action: ffa(user, channel) elif action in actions: if action == actions[0]: # challenge challenge(channel, user, args) elif action == actions[1]: # challenge_reset send_message(channel, user, challenge_reset(user)) elif action == actions[2]: # help for msg in help_messages: send_message(channel, user, msg) def clean_guns(user): """ When a challenge is created by user, challenged persons' guns only contain a string: the name of the creator. This removes all guns pointing to the creator (user), as well as the user's gun itself, thus clearing the challenge completely. """ del guns[user] for key in guns.keys(): if isinstance(guns[key], basestring) and guns[key] == user: del guns[key] xchat.hook_print('Channel Msg Hilight', handler) xchat.hook_print('Channel Message', handler) xchat.hook_print('Your Message', handler) print("\00304", __module_name__, "successfully loaded.\003")
except: xchat.prnt("Sorry, you need to input a time in seconds") elif word[1][0:3] == "off": if active == 1: active = 0 xchat.prnt("Module turned off!") else: xchat.prnt("Module already disabled!") elif word[1][0:2] == "on": if active == 0: active = 1 lastcommand = 0 xchat.prnt("Module turned on!") else: xchat.prnt("Module already enabled!") return xchat.EAT_ALL def unloading(userdata): xchat.prnt("Unloading Dict module...") # These are all XChat specific functions xchat.hook_print("Channel Msg Hilight", they_say) xchat.hook_print("Channel Message", they_say) xchat.hook_print("Private Message to Dialog", they_say) xchat.hook_print("Your Message", me_say) xchat.hook_command("dict", set_vars) xchat.hook_unload(unloading) # Print success on load xchat.prnt("Dict loaded successfully.")
for trigger, response in responses: if message.find(trigger) != -1: if response[0] == '*': xchat.get_context().command('me ' + response[1:]) else: xchat.get_context().command('say ' + response) return xchat.EAT_XCHAT return xchat.EAT_XCHAT def on_address(word, word_eol, userdata): user = word[0] message = word[1].strip() pattern = r'^' + username + r"[^A-Za-z0-9]*<(.+)><(.+)>$" m = re.match(pattern, message) if m: responses.append([m.group(1), m.group(2)]) xchat.get_context().command('say ' + '^_^') return xchat.EAT_ALL else: on_message(word, word_eol, userdata) xchat.get_context().command('say ' + 'nya?') return xchat.EAT_ALL xchat.hook_print('Channel Message', on_message) xchat.hook_print('Channel Msg Hilight', on_address)
# word[0] = 'Jane' word[1] = 'that smells bad' # word_eol[0] = 'Jane that smells bad' word_eol[1] = 'that smells bad' context = xchat.get_context() chan = context.get_info('channel') if chan not in LASTUSED: return None now = time.time() if LASTUSED[chan] + TIMEOUT >= now: # on cooldown return None if random() > CHANCE: # rolled dice, not now return None LASTUSED[chan] = now wisdom = fetchYTcomment(word[1]) if wisdom: # context.command('say {}'.format(wisdom)) print '{} \x0315"{}"\x0f'.format(YOUTUBELOGO, wisdom) else: print '{} \x0315(nothing found?)\x0f'.format(YOUTUBELOGO) pass return xchat.EAT_NONE # -- main print "\x02Loaded %s v%s\x02" % (__module_name__, __module_version__) xchat.hook_print('Channel Message', checkPrint) xchat.hook_command('ytbabble', checkCommand, help='/ytbabble string (for testing only)') print "\x02commands:\x02 /ytbabble some_text".format(CHANCE) print "\x02triggers:\x02 any text, {}/1.0 % chance of response.".format(CHANCE)
umsg = replace_arg(msg[2], arg) if found: # Append result to msgs, which will be used later, and break # so the same match isn't counted multiple times if multiple # arguments are passed. msgs.append("%s\t%s\017: %s" % (timestamp, user, umsg)) break if len(msgs) > 0: # Open a new dialog and print all found results in it. xchat.command("DIALOG Search") dialog = xchat.find_context(network, "Search") for msg in msgs: dialog.prnt(msg) else: print("\00307No results founds in %s:%s." % (network, channel)) return xchat.EAT_ALL xchat.hook_print("Your Message", new_msg) xchat.hook_print("Your Action", new_msg) xchat.hook_print("Channel Message", new_msg) xchat.hook_print("Channel Msg Hilight", new_msg) xchat.hook_print("Channel Action", new_msg) xchat.hook_print("Channel Action Hilight", new_msg) xchat.hook_command("SEARCH_ALL", search, 'a') xchat.hook_command("SEARCH_USERS", search, 'u') xchat.hook_command("SEARCH_MESSAGES", search, 'm') print("\00304", __module_name__, "successfully loaded.\003")
} args['guessed'] = used_letters args['game'] = 'hangman' args['action'] = 'display' r = requests.post('http://nmichaels.org/hangsolve.py', data=args) guess = str( BeautifulSoup(r.content).find('span', { 'class': 'guess' }).text[0]) XC.hook_timer(random.randint(2000, 5000), guess_letter) used_letters += guess # for not answering in just a moment when the task appears =) def guess_letter(arg): global game global guess game.command('say !hangman ' + guess) XC.hook_timer(4000, init_cb) XC.hook_command( "hbot", bot_cb, help= "/hbot X - hangman X times (if nothing - 1 time) or start/stop or status") XC.hook_print("Channel Message", message_cb) XC.hook_print("Channel Msg Hilight", message_cb)
hora = datetime.datetime.fromtimestamp(int(valor[2:13])).strftime('%H:%M') #Verifica se as datas e horas solicitadas para serem enviadas existem no log #Se existirem marca a linha aonde comeca e onde termina if (hora == horainicial and dia == diainicial): linhainicio = linha elif(hora == horafinal and dia == diafinal): linhafinal = linha #Se ele encontrou log para a hora e data solicitada #Cria uma nova lista com os log da conversa sem as datas e horas if(linhainicio != 0 and linhafinal != 0): novalista = text[linhainicio:linhafinal] #inicia a varial que vai ser passada para o e-mail mensagemfinal = "" #O for vai montar uma string com todo o log da conversa for linha in novalista: mensagemfinal += linha[14:-1] + '\n' #Apos montar a string passa a mensagem de log como parametro para o email enviaemail(mensagemfinal) #Fecha o arquivo de log. arquivo.close() xchat.prnt("Plugin carregado com sucesso"); xchat.hook_print("Channel Message", message_cb) xchat.hook_print("Your Message", message_cb) xchat.hook_print("Private Message to Dialog", message_cb)
if conf.remove_section(network): # Returns True if section existed # Write on disk only if configuration is actually changed conffile = open(conffileName, 'w') conf.write(conffile) conffile.close() print('Successfully removed SASL settings for network ' + network) else: print('SASL authentication is not configured for network ' + network) else: print('Usage: /SASL <-set|-unset> <network> [<nick> <password>]') return xchat.EAT_NONE xchat.hook_print('Connected', connected_cb) xchat.hook_server('AUTHENTICATE', authenticate_cb) xchat.hook_server('CAP', cap_cb) xchat.hook_server('903', sasl_90x_cb) # RPL_SASLSUCCESS xchat.hook_server('904', sasl_90x_cb) # ERR_SASLFAIL xchat.hook_server('905', sasl_90x_cb) # ERR_SASLTOOLONG xchat.hook_server('906', sasl_90x_cb) # ERR_SASLABORTED xchat.hook_server('907', sasl_90x_cb) # ERR_SASLALREADY xchat.hook_command( 'SASL', sasl_cb, help='Usage: /SASL <-set|-unset> <network> [<nick> <password>], ' + 'set or unset SASL authentication for an IRC network. Arguments <nick> and <password> are optional for -unset' )
active_pairs.add(pair) return xchat.EAT_NONE def remove_pair(word, word_eol, userdata): try: active_pairs.remove(word[1]) print "Removing %s" % word[1] except KeyError: print "No such pair is active" return xchat.EAT_NONE xchat.hook_print("Channel Message", translate) xchat.hook_command( "add_pair", add_pair, help= "/add_pair <pair> will start using the language pair to translate IRC text" ) xchat.hook_command( "remove_pair", remove_pair, help= "/remove_pair <pair> will stop using the language pair to translate IRC text" ) print "Plugin translate loaded!"
"channel": channel, "time": timestamp, "mode": mode, "nick": nick, "text": message } # Turns off automatic focusing of new tabs. xchat.command("set -quiet tab_new_to_front 0") # Opens a new window if there is none already. xchat.command("query -nofocus %s" % WINDOW_NAME) # Resets the focusing settings. xchat.command("set -quiet tab_new_to_front %d" % DEFAULT_SET_VALUE) # Fetches the context object of the window. context = xchat.find_context(server=server, channel=WINDOW_NAME) if context is not None: context.emit_print("Generic Message", OUT[userdata][0] % data, OUT[userdata][1] % data) else: # this should never happen xchat.emit_print("Generic Message", __module_name__, "Unknown error: Unable to create context object") return xchat.EAT_NONE xchat.hook_print("Channel Msg Hilight", catch_hilight, userdata="MESSAGE") xchat.hook_print("Channel Action Hilight", catch_hilight, userdata="ACTION") print(__module_name__, __module_version__, "script loaded\003")
try: if word[1].lower() == "add": addAop(word[2:]) elif word[1].lower() == "remove": removeAop(word[2:]) elif word[1].lower() == "list": printList() else: printHelp() except IndexError: printHelp() return xchat.EAT_ALL xchat.hook_print("Join", processJoin) xchat.hook_command("xaop", xaop_callback, help="/xaop add|remove|list|help") # Load the aop list from a file: try: f = open(CONFIG_FILE_LOCATION, "rb") aopList = pickle.load(f) f.close() except IOError: aopList = [] except EOFError: aopList = [] def unload_cb(userdata):
else: for sI, sV in dSettings.iteritems(): sDots = '.'*(29 - len(sI)) sTmpStr = "%s\x0312%s\x0f\x0311:\x0f %s" % (sI, sDots, sV) xchat.prnt(sTmpStr) #endfor #endif return xchat.EAT_ALL #enddef lEvents4L4l = [ "Channel Action" , "Channel Action Hilight" , "Channel Message" , "Channel Msg Hilight" ] for sI in lEvents4L4l: xchat.hook_print(sI, LookForLink, sI) #endfor xchat.hook_command("yti", Settings) xchat.prnt("Loaded %s version %s." % (__module_name__, __module_version__)) GetCategories() import sys if len(sys.argv) > 1: LookForLink(['', sys.argv[1], ''], ['', sys.argv[1], ''], None)
xchat.emit_print("Server Error", "Can't find user %s" % word[1]) else: xchat.command('whois %s' % word[1]) return xchat.EAT_ALL def getLocationJoinCB(word, word_eol, userdata): loc = word[2].split('@')[1] printLocationLine(word[0], loc) return xchat.EAT_NONE def unloadCB(userdata): print colordecode("%C4Plugin %B" + __module_name__ + "%B " + __module_version__ + " unloaded.") try: cmd = __module_name__.upper() xchat.hook_command(cmd, getLocationCB, help="/" + cmd + " <userid> Gets location of user") xchat.hook_print("Join", getLocationJoinCB) xchat.hook_print("Whois Name Line", getLocationWhoisNameCB) xchat.hook_unload(unloadCB) print colordecode("%C4Plugin %B" + __module_name__ + "%B " + __module_version__ + " loaded.") except: print "can't hook callbacks to xchat" if __name__ == '__main__': pass
'Rauchen in der Schwangerschaft schadet Ihrem Kind.', 'Schützen Sie Kinder – lassen Sie sie nicht Ihren Tabakrauch einatmen!', 'Ihr Arzt oder Apotheker kann Ihnen dabei helfen, das Rauchen aufzugeben.', 'Rauchen macht sehr schnell abhängig: Fangen Sie gar nicht erst an!', 'Wer das Rauchen aufgibt, verringert das Risiko tödlicher Herz- und Lungenerkrankungen.', 'Rauchen kann zu einem langsamen und schmerzhaften Tod führen.', 'Hier finden Sie Hilfe, wenn Sie das Rauchen aufgeben möchten: Bundeszentrale für gesundheitliche Aufklärung (BZgA) Tel.: 01805-313131, www.rauchfrei-info.de.', 'Rauchen kann zu Durchblutungsstörungen führen und verursacht Impotenz.', 'Rauchen lässt Ihre Haut altern.', 'Rauchen kann die Spermatozoen schädigen und schränkt die Fruchtbarkeit ein.', 'Rauch enthält Benzol, Nitrosamine, Formaldehyd und Blausäure.' ] def on_message(word, word_eol, userdata): global timer words = word[1].split(" ") if xchat.get_info('channel').startswith('#chaostal') and 'rauchen' in words: timer = xchat.hook_timer(2000, send_raucher_message) def send_raucher_message(userdata): global timer xchat.unhook(timer) destination = xchat.find_context(channel='#chaostal') destination.command('say ' + choice(SPREUCHE)) xchat.hook_print('Channel Message', on_message) print "%s loaded." % __module_name__
else: found_who = i break if found_who: colour = PEOPLE[found_who]['colour'] if isinstance(colour, int): colour = '\003%d' % colour elif colour in MIRC_COLOURS: colour = MIRC_COLOURS[colour] mesg = word_eol[1] # print('... firstchar %d lastchar %d' % (ord(mesg[0]), ord(mesg[-1]))) if mesg.startswith(colour): # probably one of ours return xchat.EAT_NONE else: mesg = colour + MIRC_COLOUR_FIND.sub('', mesg.strip()) + MIRC_COLOUR_RESET xchat.emit_print("Channel Message", nick, mesg, '', nick_to_prefix(nick)) return xchat.EAT_ALL return xchat.EAT_NONE # -- main for ccc in PEOPLE: PEOPLE[ccc]['regexp'] = ircglob_to_regexp(ccc) # print PEOPLE[ccc]['regexp'].pattern xchat.hook_print('Channel Message', colour_someone) print "loaded %s v%s" % (__module_name__, __module_version__) #print "loaded %s v%s (no commands)" % (__module_name__, __module_version__)
cmd, params = word[1].split(' ', 1) else: cmd, params = word[1], None context = xchat.get_context() chan = context.get_info('channel') if cmd == '!giphy': if not params: return xchat.NONE if chan in LASTUSED: now = time.time() if LASTUSED[chan] + TIMEOUT >= now: context.command('msg {} "!giphy" on cooldown'.format(word[0])) else: found = fetchAPIresults(params) if found: context.command('me found \x1f{}\x0f'.format(found)) else: context.command('me couldn\'t search Giphy') print '*** error searching Giphy' LASTUSED[chan] = now return xchat.EAT_PLUGIN # -- main print "\x02Loaded %s v%s\x02" % (__module_name__, __module_version__) xchat.hook_print('Channel Message', checkPrint) xchat.hook_print('Your Message', checkPrint) xchat.hook_command('giphy', checkCommand, help='"/giphy" for help') print "\x02commands:\x02 /giphy" print "\x02triggers:\x02 !giphy"
if checklist.values().count(checklist[user]) > 1: clones.append((checklist[user], user)) if clones: clones.sort() print color["red"] + "The following clones were found in " + \ thecontext.get_info('channel') + ":" for clone in clones: print color["blue"] + clone[1] + " " + clone[0] else: print color["blue"] + "No clones found" return xchat.EAT_ALL load_vars() #---Hooks---#000000#FFFFFF------------------------------------------------------ xchat.hook_print('Channel Message', on_text) xchat.hook_print('Join', on_join) xchat.hook_print('Part', on_part) xchat.hook_print('Change Nick', on_change_nick) xchat.hook_print('WhoIs Name Line', on_whois_nameline) xchat.hook_print('WhoIs Channel/Oper Line', on_whois_channels) xchat.hook_print('Notice', on_notice) xchat.hook_print('Channel DeVoice', on_devoice) xchat.hook_print('Channel Voice', on_voice) xchat.hook_print('Ban List', on_banlist) xchat.hook_command('clonescan', clonescan_local, help="/clonescan") #LICENSE GPL #Last modified 10-07-08
message) if history else message dechoded, _ = choder.dechode(enchoded) formatted = RE_cocks.sub(dechoded, word[1]) del buffer[word[0]] xchat.emit_print("Channel Message", '\0034\002\037' + word[0] + '\0034\002\037', formatted.encode('utf-8'), "") return xchat.EAT_XCHAT else: buffer[word[0]] = "{} {}".format(history, message) if history else message return xchat.EAT_XCHAT for event in events: xchat.hook_print(event, cocktography_cb) def enchode_cb(word, word_eol, userdata): input = word_eol[1][:150] s = choder.enchode(input, 2, 340) buffer["input"] = s.splitlines() for dongs in buffer["input"]: xchat.get_context().command('say ' + dongs) del buffer["input"] xchat.emit_print( "Channel Message", '\0034\002\037' + xchat.get_info('nick') + '\0034\002\037', input, "") return xchat.EAT_XCHAT
elif command == "#give": fact = getfact(title) if fact: send_message(channel, "%s: %s" % (action, fact)) elif command.startswith("#"): title = command[1:] fact = getfact(title) if fact: send_message(channel, '\00307' + fact) def getfact(title): c.execute("SELECT * FROM facts WHERE title=?", (title, )) try: fact = c.fetchone()[1] if fact.startswith("<reply>"): fact = fact.split("<reply>", 1)[1].strip() else: fact = "%s: %s" % (title, fact) return "%s" % fact except TypeError: return None raise xchat.hook_print('Channel Msg Hilight', chan_command) xchat.hook_print('Channel Message', chan_command) xchat.hook_print('Your Message', chan_command) print("\00304", __module_name__, "successfully loaded.\003")
else: xchat.prnt('Found %s' % version) ircrypt_options['BINARY'] = ircrypt_gpg_binary def test(word, word_eol, userdata): xchat.prnt(word[-2]) return xchat.EAT_ALL # Initialize ircrypt_init() # Chek if gpg binary is set ircrypt_check_binary() # hook for ircrypt command xchat.hook_command('ircrypt', ircrypt_command_hook, help=ircrypt_help_text) # hook for encryption xchat.hook_command('', ircrypt_encrypt_hook) # hook for decryption xchat.hook_print('Channel Message', ircrypt_decrypt_hook, 'Channel Message') # hook to check for asymmetric encryption in notices xchat.hook_print('Notice', ircrypt_notice_hook) # Unload xchat.hook_unload(ircrypt_unload)
if len(word) >= 3 and word[2] != '--network': if word_eol[2]=="1" or word_eol[2]=="True" or word_eol[2]=="true": key.aes = True if word_eol[2]=="0" or word_eol[2]=="False" or word_eol[2]=="false": key.aes = False KEY_MAP[id_] = key elif len(word) >= 5 and word[2] == '--network': if word_eol[4]=="1" or word_eol[4]=="True" or word_eol[4]=="true": key.aes = True if word_eol[4]=="0" or word_eol[4]=="False" or word_eol[4]=="false": key.aes = False print 'Key aes', id_, 'set', key.aes return xchat.EAT_ALL import xchat xchat.hook_command('key', key, help='show information or set key, /key <nick> [<--network> <network>] [new_key]') xchat.hook_command('key_exchange', key_exchange, help='exchange a new key, /key_exchange <nick>') xchat.hook_command('key_list', key_list, help='list keys, /key_list') xchat.hook_command('key_load', key_load, help='load keys, /key_load') xchat.hook_command('key_pass', key_pass, help='set key file pass, /key_pass password') xchat.hook_command('aes', aes, help='aes #channel/nick 1|0 or True|False') xchat.hook_command('key_remove', key_remove, help='remove key, /key_remove <nick>') xchat.hook_server('notice', dh1080) xchat.hook_print('Channel Message', decrypt_print, 'Channel Message') xchat.hook_print('Change Nick', change_nick) xchat.hook_print('Private Message to Dialog', decrypt_print, 'Private Message to Dialog') xchat.hook_server('332', server_332) xchat.hook_command('', encrypt_privmsg) xchat.hook_unload(unload) load()
__module_name__ = "Unban/Rejoin" __module_version__ = "1.0" __module_description__ = "Unbans self from channel and rejoins automatically" import xchat import time def banned_cb(word, word_eol, userdata): channel = word[0] timer = xchat.hook_timer(3000, timer_cb, channel) return xchat.EAT_NONE def timer_cb(channel): xchat.command("msg chanserv unban " + channel + " " + xchat.get_info("nick")) time.sleep(1) xchat.command("join " + channel) return 0 xchat.hook_print("Banned", banned_cb)
if len(word_eol) > 2: # Set banOpts["*"]["irc_kick_message"] = word_eol[2] xchat.prnt("%s set to: %s" % (word[1],word_eol[2])) else: dots = 29-len(word[1]) try: irc_kick_message = banOpts["*"]["irc_kick_message"] except KeyError: irc_kick_message = None xchat.prnt(word[1]+"\00318"+("."*dots)+"\00319:\x0f "+irc_kick_message) #endif return xchat.EAT_XCHAT #endif return xchat.EAT_NONE #enddef xchat.hook_print("Join", CheckJoin) xchat.hook_print("You Join", BanTimerGo, True) xchat.hook_server("352", CheckWhoRet) xchat.hook_command("set",SetMessage) for x in ["b","ban"]: xchat.hook_command(x,BanNick,None,xchat.PRI_HIGHEST) for x in ["-b","ub","unban"]: xchat.hook_command(x,UnbanNick,None,xchat.PRI_HIGHEST) for x in ["k","kick"]: xchat.hook_command(x,KickNick,(1,2,None),xchat.PRI_HIGHEST) for x in ["kb","bk","kickban"]: xchat.hook_command(x,BanNick,True,xchat.PRI_HIGHEST) LoadINIish((banTimes,"bantimes",int)) xchat.hook_unload(SaveINIish,(banTimes,"bantimes")) LoadINIish((bannedNicks,"bannednicks",str)) xchat.hook_unload(SaveINIish,(bannedNicks,"bannednicks")) LoadINIish((banOpts,"banopts",str)) xchat.hook_unload(SaveINIish,(banOpts,"banopts")) xchat.prnt("Loaded %s version %s." % (__module_name__,__module_version__))
cn = context.get_info("channel") okChannels[cn] = True xchat.prnt("Automatically voicing newcomers in "+cn) return xchat.EAT_ALL #enddef def UnVoiceChannel(word,word_eol,userdata): global okChannels context = xchat.get_context() cn = context.get_info("channel") del okChannels[cn] xchat.prnt("No longer automatically voicing newcomers in "+cn) return xchat.EAT_ALL #enddef def ResetChannel(word,word_eol,userdata): global hostsThatJoined context = xchat.get_context() del hostsThatJoined hostsThatJoined = {} cn = context.get_info("channel") xchat.prnt("Everyone is now a newcomer in "+cn) return xchat.EAT_ALL #enddef xchat.hook_print("Join", CheckJoin) xchat.hook_command("autovoice",VoiceChannel,False) xchat.hook_command("unautovoice",UnVoiceChannel,False) xchat.hook_command("resetvoice",ResetChannel,False) xchat.prnt("Loaded %s version %s." % (__module_name__,__module_version__))
#!/usr/bin/python3 __module_name__ = "Cancel's HelloBot" __module_version__ = "1.0.0" __module_description__ = "HelloBot by Cancel" print("\0034", __module_name__, __module_version__, "has been loaded\003") import xchat import os import re def on_join(word, word_eol, userdata): triggernick, triggerchannel, triggerhost = word #we could also do triggernick = word[0] #we could also do triggernick = word[1] you get the picture destination = xchat.get_context() destination.command("say Hello " + triggernick + " and welcome to " + triggerchannel) xchat.hook_print('Join', on_join)
try: if word[1].lower() == "add": addAop(word[2:]) elif word[1].lower() == "remove": removeAop(word[2:]) elif word[1].lower() == "list": printList() elif word[1].lower() == "allop": doAllOp() else: printHelp() except IndexError: printHelp() return xchat.EAT_ALL xchat.hook_print("Join",processJoin) xchat.hook_command("xaop", xaop_callback, help="/xaop add|remove|list|help|allop") # Load the aop list from a file: try: f = open(CONFIG_FILE_LOCATION,"r") aopList = pickle.load(f) f.close() except IOError: aopList = [] except EOFError: aopList = []
''' def addJob(word, word_eol, userdata): channel = xchat.get_info('channel') key = channel + " " + word[0].lower() if (AUTOUSER.has_key(key)): dest, src = AUTOUSER[key] ThreadController.addJob( (xchat.get_context(), word[0], src, dest, word[1])) return xchat.EAT_NONE xchat.hook_print("Channel Message", addJob) ''' Shuts down the threads and thread controller when unloading the module. ''' def unload_translator(userdata): ThreadController.worker.kill = True ThreadController.addJob(None) print 'Translator is unloaded' xchat.hook_unload(unload_translator) # Load successful, print message print 'Translator script loaded successfully.'