.. _fbf.plugs.core.irc: irc ~~~ .. automodule:: fbf.plugs.core.irc :show-inheritance: :members: :undoc-members: CODE ---- :: # fbf/plugs/core/irc.py # # """ irc related commands. """ .. _fbf.plugs.core.irc_fbf_imports: fbf imports -------------- :: from fbf.lib.callbacks import callbacks from fbf.lib.partyline import partyline from fbf.lib.commands import cmnds from fbf.lib.examples import examples from fbf.lib.fleet import getfleet from fbf.lib.wait import waiter import fbf.lib.threads as thr .. _fbf.plugs.core.irc_basic_imports: basic imports ---------------- :: import queue import time .. _fbf.plugs.core.irc_define_: define --------- :: ignorenicks = [] .. _fbf.plugs.core.irc_broadcast_command: broadcast command -------------------- :: def handle_broadcast(bot, ievent): """ arguments: - broadcast txt to all joined channels. """ if not ievent.rest: ievent.missing('') return ievent.reply('broadcasting') getfleet().broadcast(ievent.rest) partyline.say_broadcast(ievent.rest) ievent.reply('done') cmnds.add('broadcast', handle_broadcast, 'OPER', threaded=True) examples.add('broadcast', 'send a message to all channels and dcc users', 'broadcast good morning') .. _fbf.plugs.core.irc_jump_command: jump command --------------- :: def handle_jump(bot, ievent): """ arguments: - change server. """ if bot.jabber: ievent.reply('jump only works on irc bots') return if len(ievent.args) != 2: ievent.missing(' ') return (server, port) = ievent.args ievent.reply('changing to server %s' % server) bot.shutdown() bot.cfg.server = server bot.cfg.port = port bot.connect() ievent.done() cmnds.add('jump', handle_jump, 'OPER') examples.add('jump', 'jump .. switch server', 'jump localhost 6667') .. _fbf.plugs.core.irc_nick_command: nick command --------------- :: def handle_nick(bot, ievent): """ arguments: - change bot's nick. """ if bot.jabber: ievent.reply('nick works only on irc bots') return try: nick = ievent.args[0] except IndexError: ievent.missing('') return ievent.reply('changing nick to %s' % nick) bot.donick(nick, setorig=True, save=True) ievent.done() cmnds.add('nick', handle_nick, 'OPER', threaded=True) examples.add('nick', 'nick .. set nick of the bot', 'nick mekker') .. _fbf.plugs.core.irc_sendraw_command: sendraw command ------------------ :: def handle_sendraw(bot, ievent): """ arguments: - send raw text to the server. """ ievent.reply('sending raw txt') bot._raw(ievent.rest) ievent.done() cmnds.add('sendraw', handle_sendraw, ['OPER', 'SENDRAW']) examples.add('sendraw', 'sendraw .. send raw string to the server', 'sendraw PRIVMSG #test :yo!') .. _fbf.plugs.core.irc_nicks_command: nicks command ---------------- :: nickresult = [] def handle_nicks(bot, event): """ no arguments - return nicks on channel. """ if bot.type != 'irc': event.reply('nicks only works on irc bots') ; return event.ctl = 2 def aggregate(bot, e): global nickresult nickresult.extend(e.txt.split()) def nickscb(bot, e): global nickresult event.reply("nicks on %s (%s): " % (event.channel, bot.cfg.server), nickresult) nickresult = [] waiter.remove("fbf.plugs.core.irc") w353 = waiter.register('353', aggregate) w366 = waiter.register('366', nickscb) event.reply('searching for nicks') bot.names(event.channel) time.sleep(5) waiter.ready(w353) waiter.ready(w366) cmnds.add('nicks', handle_nicks, ['OPER', 'USER'], threaded=True) examples.add('nicks', 'show nicks on channel the command was given in', 'nicks') .. _fbf.plugs.core.irc_action_command: action command ----------------- :: def handle_action(bot, ievent): """ arguments: - make the bot send an action string. """ try: channel, txt = ievent.rest.split(' ', 1) except ValueError: ievent.missing(' ') return bot.action(channel, txt) ievent.done() cmnds.add('action', handle_action, ['ACTION', 'OPER']) examples.add('action', 'send an action message', 'action #test yoo dudes') .. _fbf.plugs.core.irc_say_command: say command -------------- :: def handle_say(bot, ievent): """ aguments: - make the bot say something. """ try: channel, txt = ievent.rest.split(' ', 1) except ValueError: ievent.missing(' ') return bot.say(channel, txt) ievent.done() cmnds.add('say', handle_say, ['SAY', 'OPER'], speed=1) examples.add('say', 'send txt to channel/user', 'say #test good morning') .. _fbf.plugs.core.irc_server_command: server command ----------------- :: def handle_server(bot, ievent): """ no arguments - show the server to which the bot is connected. """ ievent.reply(bot.cfg.server or "not connected.") cmnds.add('server', handle_server, 'OPER') examples.add('server', 'show server hostname of bot', 'server') .. _fbf.plugs.core.irc_voice_command: voice command ---------------- :: def handle_voice(bot, ievent): """ arguments: - give voice. """ if bot.type != 'irc': ievent.reply('voice only works on irc bots') return if len(ievent.args)==0: ievent.missing('') return ievent.reply('setting voice on %s' % str(ievent.args)) for nick in Set(ievent.args): bot.voice(ievent.channel, nick) ievent.done() cmnds.add('voice', handle_voice, 'OPER') examples.add('voice', 'give voice to user', 'voice test')