def __init__( self ): self.last_msg = -1 self.msg_flood_limit = 0.25 with open(os.path.join(os.path.dirname(__file__), 'ircbot.conf')) as f: data = json.load(f) self.servers = data['servers'] self.select_server(0) self.db = sqlite3.connect( os.path.join( os.path.dirname( __file__ ), 'ircbot.sqlite3' ), check_same_thread = False ) cursor = self.db.cursor() try: cursor.execute( 'select * from config limit 1' ) except sqlite3.OperationalError: # table no exist cursor.execute( 'create table config ( `group` varchar(100), `key` varchar(100), `value` varchar(100) NULL )' ) cursor.close() self.modules = ModuleManager( self ) self.channel_ops = {} server = self.current_server['host'] port = self.current_server['port'] if 'port' in self.current_server else 6667 password = self.current_server['password'] if 'password' in self.current_server else '' nickname = self.current_server['nickname'] if len(password): SingleServerIRCBot.__init__( self, [( server, port, password )], nickname, nickname, ipv6 = True ) else: SingleServerIRCBot.__init__( self, [( server, port )], nickname, nickname, ipv6 = True ) for module_name in self.modules.get_available_modules(): self.modules.enable_module( module_name )
def __init__(self): config = lib.aiml.configFile.get() try: server = config['irc.server'] if server == "": raise KeyError except KeyError: server = raw_input("Server: ") try: port = int(config['irc.port']) except: port = raw_input("Port: ") try: nickname = config['irc.nick'] if nickname == "": raise KeyError except KeyError: nickname = raw_input("Nick: ") try: channel = config['irc.channel'] if channel == "": raise KeyError except KeyError: channel = raw_input("Channel: ") SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel try: self._maxdelay = int(config['general.maxdelay']) except KeyError: self._maxdelay = 0 self.start()
def __init__(self, parent, server_info, nickname ="orcbot"): server = server_info[0] port = int(server_info[1]) self.orc = parent SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
def __init__(self, channel, nickname, server, password, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.server = server self.channel = channel self.nickname = nickname self.password = password self.version = '1.5'
def __init__(self, server_list, nick, real, channel, listen_addr=None, script=None, deop=True): SingleServerIRCBot.__init__(self, server_list, nick, real, reconnection_interval=30) self.channel = decode(channel) self.script = decode(script) self.listen_addr = listen_addr self.deop = deop self.match = '^!' self.match_timer = 0 self.script_modified = 0 self.dispatchers = {} self.irc_socket = None self.send_timer = 0 self.send_buffer = [] self.recv_buffers = {} self.setup_logging() self.setup_throttling() self.setup_listener() self.running = False
def __init__(self, rcfeed, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.server = server self.rcfeed = rcfeed self.nickname = nickname globals()['lastsulname'] = None globals()['lastbot'] = 1
def __init__(self, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.version = '0.4.6' self.github = 'https://github.com/Nikola-K/BBBot/' self.nickname = nickname self.initial_channels = brba.initialch self.banned_users = brba.banned self.admin = brba.admin self.authorized = brba.auth self.ircpass = brba.password self.cc = '#' + brba.cc self.debug = False self.logdebug = False self.maxlen = 440 self.cmdlimits = {'!stream': 0, '!download': 0, '!i': 0, 'notify': 20, 'timelimit': 10, 'notifytime': 10} self.allcmds = ['bot', '.time', '.ban', '.unban', '.ath', '.rmath', '.join', '.quit', '.say', '.add', '.remove', '.update', '!i', '!download', '!stream', '!imdb', '!suggest', '.help' ] self.disabledcmds = ['!imdb', '!download'] self.loggedinusers = [] self.restrictedcmds = ['.time', '.ban', '.unban', '.ath', '.rmath', '.join', '.quit', '.say', '.add', '.remove', '.update' ] self.cmdqueue = []
def __init__(self, channels, nickname, password, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port), password], nickname, nickname) self.channelsDict = channels self.password = password self.botNick = nickname self.channels = {} self.logger = Logger(self.channels)
def __init__(self, server, port, server_pass=None, channels=[], nick="timber", nick_pass=None, format=default_format, commands=default_commands, operators=OPERATORS, feed_commands=default_feed_commands, alias_dict=default_alias_dict): SingleServerIRCBot.__init__(self, [(server, port, server_pass)], nick, nick) self.chans = [x.lower() for x in channels] self.format = format self.commands = commands self.alias_dict = alias_dict self.alias_map = self.make_alias_map() self.feed_commands = feed_commands self.operators = operators self.set_ftp() self.count = 0 self.nick_pass = nick_pass self.load_channel_locations() print "Logbot %s" % __version__ print "Connecting to %s:%i..." % (server, port) print "Press Ctrl-C to quit"
def __init__(self, channel, nickname, server, port): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.nickname = nickname self.queue = botcommon.OutputManager(self.connection) self.queue.start() self.start()
def __init__(self, name = bot['name'], server = bot['server'], ssl = bot['ssl'], password = bot['password'], port = bot['port'], channel = bot['channel'], **kwargs): SingleServerIRCBot.__init__(self, [(server, port)], name, "IRCBot available on : https://git.io/vHtZ6",password=password, ssl=ssl) self._name = name self._channel = channel self._server = server self._port = port self._ssl = ssl self._stdout = kwargs.pop('stdout', sys.stdout) self._stat = kwargs.pop('stat', {}) self._prompt.update(kwargs.pop('prompt', {})) self._function = kwargs.pop('function', bot.get('function', True)) function = kwargs.pop('function_access', {}) self.__function__ = { key[3:]: function[key[3:]] if key[3:] in function and type(function[key[3:]]) is int else bot.get('__function__', 0) for key in dir(self) if key.startswith('do_') } self.__function_intervall = kwargs.pop('function_intervall', 5) self.__next_function = datetime.now()
def __init__(self, server, port, server_pass=None, channels=[], nick="timber", nick_pass=None, format_html=HTML): SingleServerIRCBot.__init__(self, [(server, port, server_pass)], nick, nick) self.chans = [x.lower() for x in channels] self.format_html = format_html self.count = 0 self.nick_pass = nick_pass # create the log directory if not found if not os.path.exists(LOG_FOLDER): os.makedirs(LOG_FOLDER) for filename in os.listdir('.'): if '.css' in filename: fp = os.path.join(os.getcwd(), filename) os.system('cp {} {}'.format(fp, LOG_FOLDER)) # create the channel index when started with open(os.path.join(LOG_FOLDER, 'index.html'), 'w') as index: index.write(CHANNEL_HEADER.format(BOTS)) for channel in CHANNELS: link = channel.replace('#', '%23') index.write('<p><a href="{}/index.html">{}</a></p>\n'.format(link, channel)) index.write(CHANNEL_FOOTER) # create channel directories if not found for channel in CHANNELS: channel_directory = os.path.join(LOG_FOLDER, channel) if not os.path.isdir(channel_directory): os.makedirs(channel_directory) else: # check for index in channel directory if not os.path.isfile(os.path.join(channel_directory, 'index.html')): self.create_index(channel) print 'JT Logbot {}'.format(__version__) print "Connecting to {}:{}...".format(server, port) print "Press Ctrl-C to quit"
def __init__(self, channel, nickname, nickpass, server, port=default_port, debug=False, moderation=True): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel # self.desired_nickname is the nickname we _want_. The nickname we actually # have at any particular time is c.get_nickname(). self.desired_nickname = nickname self.nickpass = nickpass self.debug = debug self.members_in_room = [] self.moderation = moderation self.queue = OutputManager(self.connection) self.queue.start() try: self.start() except KeyboardInterrupt: self.connection.quit("Ctrl-C at console") print "Quit IRC." except Exception, e: self.connection.quit("%s: %s" % (e.__class__.__name__, e.args)) raise
def __init__(self, site, channel, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.site = site self.lang = site.language() self.apiURL = u'https://' + self.lang + u'.' + site.family.name + u'.org/w/api.php?action=query&meta=siteinfo&siprop=statistics&format=xml' self.logname = u'ircbot/artnos' + self.lang + u'.log' ns = [] for n in site.namespaces(): if isinstance(n, tuple): # I am wondering that this may occur! ns += n[0] else: ns += [n] #self.other_ns = re.compile(u'14\[\[07(' + u'|'.join(ns) + u')') #self.api_url = self.site.api_address() #self.api_url += 'action=query&meta=siteinfo&siprop=statistics&format=xml' #self.api_found = re.compile(r'articles="(.*?)"') self.re_edit = re.compile( r'^C14\[\[^C07(?P<page>.+?)^C14\]\]^C4 (?P<flags>.*?)^C10 ^C02(?P<url>.+?)^C ^C5\*^C ^C03(?P<user>.+?)^C ^C5\*^C \(?^B?(?P<bytes>[+-]?\d+?)^B?\) ^C10(?P<summary>.*)^C' .replace('^B', '\002').replace('^C', '\003').replace('^U', '\037')) self.re_move = re.compile( ur'^C14\[\[^C07(?P<page>.+?)^C14]]^C4 move^C10 ^C02^C ^C5\*^C ^C03(?P<user>.+?)^C ^C5\*^C ^C10(?P<action>.+?) \[\[^C02(?P<frompage>.+?)^C10]] to \[\[(?P<topage>.+?)]]((?P<summary>.*))?^C' .replace('^C', '\003')) self.re_move_redir = re.compile( ur'^C14\[\[^C07(?P<page>.+?)^C14]]^C4 move_redir^C10 ^C02^C ^C5\*^C ^C03(?P<user>.+?)^C ^C5\*^C ^C10(?P<action>.+?) \[\[^C02(?P<frompage>.+?)^C10]] to \[\[(?P<topage>.+?)]] over redirect: ((?P<summary>.*))?^C' .replace('^C', '\003')) self.re_delete_redir = re.compile( ur'^C14\[\[^C07(?P<page>.+?)^C14]]^C4 delete_redir^C10 ^C02^C ^C5\*^C ^C03(?P<user>.+?)^C ^C5\*^C ^C10(?P<action>.+?) \[\[^C02(?P<frompage>.+?)^C10\]\](?P<reason>.*?):(?P<comment>.*?„\[\[(?P<topage>.*?\]\])”)^C' .replace('^C', '\003'))
def __init__(self, channel, server, port=6667, password=None, name="beardbot", noadmin=False): SingleServerIRCBot.__init__(self, [(server, port, password)], name, "The Beardy-Based Botulator") # The channel the bot is a member of self.channel = channel # The last place a message was recieved from (used by "reply") self.last_message_sender = self.channel # If bot should have no administrators self.noadmin = noadmin # The loaded modules self.modules = {} #list of nicks to ignore self.ignore = [] # Try to load previously loaded modules try: old_modules = pickle.load(open(self.channel + "_modules.db", "r")) for module in old_modules: try: self.load_module(module) except Exception, e: traceback.print_exc(file=sys.stdout) except: # Otherwise just start the admin try: self.load_module("admin") except Exception, e: print e
def __init__(self): config = howie.configFile.get() try: server = config['irc.server'] if server == "": raise KeyError except KeyError: server = raw_input("Server: ") try: port = int(config['irc.port']) except: port = raw_input("Port: ") try: nickname = config['irc.nick'] if nickname == "": raise KeyError except KeyError: nickname = raw_input("Nick: ") try: channel = config['irc.channel'] if channel == "": raise KeyError except KeyError: channel = raw_input("Channel: ") SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel try: self._maxdelay = int(config['general.maxdelay']) except KeyError: self._maxdelay = 0 self.start()
def __init__(self, *args, **kwargs): SingleServerIRCBot.__init__(self, *args) self.channel = kwargs['channel'] self.qpassword = kwargs['qpassword'] self.nick = args[1] self.queue = OutputManager(self.connection) self.queue.start() self.exceptions = [] self.bans = [] self.hosts = {} self.ban_for_nick_change = False try: with file('exceptions', 'r') as f: self.exceptions = pickle.load(f) except: pass try: with file('bans', 'r') as f: self.bans = pickle.load(f) except: pass try: with file('hosts', 'r') as f: self.hosts = pickle.load(f) except: pass
def __init__(self): """ Setup the robot, pulls a list of the latest phrases from the DB, sets channel list and modes. """ self.nicks, address = settings.IRC self.nick = self.nicks[0] SingleServerIRCBot.__init__(self, [address], self.nick, self.nick) self.c = Client(self.nick) # Channel related things self.c.modes = {} # Channel history self._history = {} self.c.to_join = [c for c in settings.IRC_CHANNELS] self.credentials = settings.IRC_CREDENTIALS self.output = Queue.Queue(20) self.c.verbosity = settings.VERBOSITY self.processor = None self.handler = None self.init_responders()
def __init__(self, server = SERVER): self.channel = '#takano32bot' SingleServerIRCBot.__init__(self, [(SERVER, PORT)], NICKNAME, NICKNAME) xmlrpc_host = CONFIG['skype']['xmlrpc_host'] xmlrpc_port = CONFIG['skype']['xmlrpc_port'] self.skype = xmlrpclib.ServerProxy('http://%s:%s' % (xmlrpc_host, xmlrpc_port))
def __init__(self, skype, server=SERVER): SingleServerIRCBot.__init__(self, [(SERVER, PORT)], NICKNAME, NICKNAME) xmlrpc_host = config['skype']['xmlrpc_host'] xmlrpc_port = config['skype']['xmlrpc_port'] self.skype = xmlrpclib.ServerProxy('http://%s:%s' % (xmlrpc_host, xmlrpc_port)) self.channel = "#takano32bot"
def __init__(self, rcfeed, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.server = server self.rcfeed = rcfeed self.nickname = nickname self.lastsulname = None self.lastbot = bot1
def __init__(self, channels=[], nickname="", server="", port=6667, module_list=[]): """MooBot initializer - gets values from config files and uses those unless passed values directly""" # Get values from config files and replace any of the empty ones above configs = self.get_configs() config_nick = configs['nick'] config_server = configs['server'] config_port = configs['port'] config_channels = configs['channels'] config_module_list = configs['module_list'] config_others = configs['others'] # If we are passed any values directly, use those, but if they are empty # we will fall back to the values we got from the config file if channels == []: channels = config_channels if nickname == "": nickname = config_nick if server == "": server = config_server if port == 6667: port = config_port if module_list == []: module_list = config_module_list # Now that we have our values, initialize it all SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channels = IRCDict() for channel in channels: self.channels[channel] = Channel() self.handlers = [] self.configs = config_others self.module_list = module_list
def __init__(self): """ Setup the robot, pulls a list of the latest phrases from the DB, sets channel list and modes. """ self.nicks, address = settings.IRC self.nick = self.nicks[0] SingleServerIRCBot.__init__(self, [address], self.nick, self.nick) self.c = Client(self.nick) # Channel related things self.c.modes = {} # Channel history self._history = {} self.c.to_join = [c for c in settings.IRC_CHANNELS] self.credentials = settings.IRC_CREDENTIALS self.output = Queue.Queue(20) self.c.verbosity = settings.VERBOSITY self.processor = None self.handler = None self.init_responders()
def __init__(self, server=SERVER): SingleServerIRCBot.__init__(self, [(SERVER, PORT)], NICKNAME, NICKNAME) xmlrpc_host = CONFIG['irc']['xmlrpc_host'] xmlrpc_port = CONFIG['irc']['xmlrpc_port'] self.daemon = xmlrpclib.ServerProxy('http://%s:%s' % (xmlrpc_host, xmlrpc_port)) self.channel = "#takano32bot"
def __init__(self, servers=servers, names=names, channels=channels, interval=60): print "IRC: connecting..." self.names = names SingleServerIRCBot.__init__(self, servers, random.sample(self.names, 1)[0], random.sample(names, 1)[0], interval) self.channelswanted = channels
def __init__(self, channel, nickname, server, port, sqlparams): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.nickname = nickname self.timer = TimerManager() self.cron = Chronograph() if hasSql: sql_login = dict(zip(['host', 'user', 'passwd', 'db'], sqlparams[:])) G_SQL_PARAMS.update(sql_login) self.db = OhMySQLdb() self.db.connect() self.setup() print "\033[33mself.modules : \033[m",self.modules print "\033[33mself.pubcommands : \033[m",self.pubcommands print "\033[33mself.privcommands : \033[m",self.privcommands print "\033[33mself.repubhandlers : \033[m",self.repubhandlers print "\033[33mself.pubhandlers : \033[m",self.pubhandlers print "\033[33mself.joinhandlers : \033[m",self.joinhandlers print "\033[33mself.kickhandlers : \033[m",self.kickhandlers print "\033[33mself.parthandlers : \033[m",self.parthandlers print "\033[33mself.quithandlers : \033[m",self.quithandlers print "\033[33mself.modehandlers : \033[m",self.modehandlers print "\033[33mself.nickhandlers : \033[m",self.nickhandlers print "%s ready to roll! Joining %s in %s" % (self.nickname, self.channel, server)
def __init__(self, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.sqldb = botsqlite.botsqlite('bot.db') self.connection.add_global_handler("whoreply", self.who_parser) self.is_connected = 0
def __init__(self, config, trigger='!', cb=None): self.config = config self.active = False self.joined = False self.registerNick = False self.callback = cb self.starttime = time.strftime('%H:%M on %A, %d %B', time.gmtime(time.time()) ) self.nickname = config.nickname self.password = config.password self.chanlist = config.channels self.server = config.server self.realname = self.nickname self.port = 6667 self.trigger = '!' if config.port is not None: self.port = config.port if config.trigger is not None: self.trigger = config.trigger if self.nickname is not None: self.nicklength = len(self.nickname) SingleServerIRCBot.__init__(self, [(self.server, self.port)], self.nickname, self.realname) else: raise Exception('nickname not defined, rbot init has stopped')
def __init__( self, config ): #, channel, nickname, password, server, port=6667, debug=False): self.log("Bot initialized.") self.config = config self.DEBUG = config.debug SingleServerIRCBot.__init__(self, [(config.server, config.port)], config.name, config.name) self.channel = config.channel self.nick = config.name self.nickpassword = config.password self.connection.add_global_handler("join", getattr(self, "inform_webusers"), 42) for i in [ "kick", "join", "quit", "part", "topic", "endofnames", "notopic" ]: self.connection.add_global_handler(i, getattr(self, "dump_users"), 42) # We need to distinguish between private and public messages self.connection.add_global_handler("pubmsg", getattr(self, "publicMessage"), 42) self.connection.add_global_handler("privmsg", getattr(self, "privateMessage"), 42) self.connection.add_global_handler("privnotice", getattr(self, "privateMessage"), 42) self.connection.add_global_handler("notice", getattr(self, "privateMessage"), 42) # List of active modules self.activeModules = []
def __init__(self, server, channels, nick, name, nickpass=None, recon=60): SingleServerIRCBot.__init__(self, [server], nick, name, recon) self.queue = botcommon.OutputManager(self.connection, .2) self.queue.start() self.nickname = nick self.name = name self.join_channels = channels self.plugins = []
def __init__(self, channel, nickname, server, port=6667, hub=None): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.connection.add_global_handler("all_events", self.on_all_events, -100) self.channel = channel self.chat_channel = "#pyIRDC" self.channel_users = IRCChannelUsers() self.send_queue = [] self.hub = hub
def __init__(self): self.load_settings() SingleServerIRCBot.__init__(self, [(self.server, int(self.port))], self.nickname, self.nickname) self.ircobj.execute_delayed(OPPAI_INTERVAL, self.on_timer) self.offset = 0 self.urlList = [] self.load_oppai()
def __init__(self, as): # Connect to IRC server self.as = as self.logfile = open(logFile, "a") print "Connecting to %s as %s..." % (server, nickname) SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.start()
def __init__(self, channel, nickname, server, port): self.child = pexpect.spawn(frotz_binary + " " + story_file) SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.nickname = nickname self.queue = botcommon.OutputManager(self.connection) self.queue.start() self.start()
def __init__(self, channels, nickname, password, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port), password], nickname, nickname) self.channelsDict = channels self.password = password self.botNick = nickname self.channels = {} self.logger = Logger(self.channels)
def __init__(self, main_channel, pswd, spy_channel, nickname, server, main): SingleServerIRCBot.__init__(self, [(s, 6667) for s in server], main, nickname, nickname) self.main = main self.main_channel = main_channel self.spy_channel = spy_channel self.pswd = pswd
def __init__(self, channel, nickname, server, port): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.nickname = nickname self.queue = botcommon.OutputManager(self.connection) self.queue.start() self.inputthread = UDPInput(self, ('localhost', 4242)) self.inputthread.start() self.start()
def __init__(self, server_list, nickname, channel): SingleServerIRCBot.__init__(self, server_list, nickname, nickname) self.channel = channel # for all other possible events to handle, see irclib.py > numeric_events, generated_events # and protocol_events self.my_names.append(nickname) self.startTime = datetime.datetime.now() self.loadPlugins()
def __init__(self, options): SingleServerIRCBot.__init__( self, [(options.host, options.port, None)], options.nick, options.nick) self._log_file_name = options.file self._log_file = None self._channels_to_join = [c.lower() for c in options.channels]
def __init__(self, channel, nickname, server, password, port=6667): SingleServerIRCBot.__init__(self, [(server, port, "%s:%s" % (nickname, password))], nickname, nickname) self.server = server self.channel = channel self.nickname = nickname self.password = password self.buildRegex() self.buildWhitelist()
def __init__(self, refresh, nickname, server, port=6667, password=None): # Split the refresh path such that we have the host and a target rSplit = refresh.split('/') self.refreshHost = rSplit[0] self.refreshTarget = '/'.join(rSplit[1:]).strip() # Join stuff together self.config = Config() # Init the config parser self.floodProtect = {} # Dictionary for flood protect goes source->last time triggered print "Target is on %s at %s" % (self.refreshHost, self.refreshTarget) SingleServerIRCBot.__init__(self, [(server, port, password)], nickname, nickname)
def __init__(self, site, channel, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.site = site self.other_ns = re.compile(u'14\[\[07(' + u'|'.join(site.namespaces()) + u')') self.api_url = self.site.api_address() self.api_url += 'action=query&meta=siteinfo&siprop=statistics&format=xml' self.api_found = re.compile(r'articles="(.*?)"') self.re_edit = re.compile(r'^C14\[\[^C07(?P<page>.+?)^C14\]\]^C4 (?P<flags>.*?)^C10 ^C02(?P<url>.+?)^C ^C5\*^C ^C03(?P<user>.+?)^C ^C5\*^C \(?^B?(?P<bytes>[+-]?\d+?)^B?\) ^C10(?P<summary>.*)^C'.replace('^B', '\002').replace('^C', '\003').replace('^U', '\037'))
def __init__(self, channel="#Bitcoin-Watch", nickname="bcbot", server="chat.freenode.net", port=6667, realname="Bitcoin monitoring bot https://github.com/davesteele/python-bitcoin-talk"): SingleServerIRCBot.__init__(self, [(server, port)], nickname, realname) self.channel = channel self.txCallbacks = []
def __init__(self, conn, channels, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.komconn = conn self.rlock = threading.RLock() self.channelstouse = list(channels[:]) self.welcomed = 0 print dir(self.connection) print "init"
def __init__(self, channel, eventmanager, conn): self.conn = conn self.channel = channel self.nickname = "chuggle" + repr(random.randint(1, 9999)) self.port = 6667 self.server = "browne.wikimedia.org" SingleServerIRCBot.__init__(self, [(self.server, self.port)], self.nickname, self.nickname) self.buffer = [] self.em = eventmanager
def __init__(self, channels=[], nickname="", password="", realname="", server="", port=6667, module_list=[], encoding=""): """MooBot initializer - gets values from config files and uses those unless passed values directly""" Debug("possible config files: " + ", ".join(self.config_files)) # Get values from config files and replace any of the empty ones above configs = self.get_configs() config_nick = configs['nick'] config_username = configs['username'] config_realname = configs['realname'] config_server = configs['server'] config_port = configs['port'] config_encoding = configs['encoding'] config_password = configs['password'] config_channels = configs['channels'] config_module_list = configs['module_list'] config_others = configs['others'] # If we are passed any values directly, use those, but if they are empty # we will fall back to the values we got from the config file # for var in \ # ['channels', 'nickname', 'username', 'server', # 'port', 'module_list', 'others']: # if kwargs.has_key(var): # if kwargs.has_key('channels'): channels = kwargs['channels'] # else: channels = config_channels if channels == []: channels = config_channels if nickname == "": nickname = config_nick if realname == "": realname = config_realname if server == "": server = config_server if port == 6667: port = config_port if password == "": password = config_password if module_list == []: module_list = config_module_list if encoding == "": encoding = config_encoding # Now that we have our values, initialize it all SingleServerIRCBot.__init__( self, [(server, port, password, encoding.upper())], nickname, realname) self.serve_nick = config_nick self.serve_password = config_password self.serve_channels = [ channel for channel in channels if channel.strip() ] self.channels = IRCDict() self.handlers = {} self.configs = config_others self.module_list = module_list
def __init__(self, channel, nickname, server, port, password=None): if password: SingleServerIRCBot.__init__(self, [(server, port, password)], nickname, nickname) else: SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.nickname = nickname self.queue = botcommon.OutputManager(self.connection) self.queue.start() self.start()
def __init__(self, channel, nickname, server, port): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.command_count = 0 self.queue_path = '/path/to/queue.csv' self.channel = channel self.nickname = nickname self.queue = botcommon.OutputManager(self.connection) self.queue.start() self.init_whitelist() self.start()
def __init__( self, channel="#Bitcoin-Watch", nickname="bcbot", server="chat.freenode.net", port=6667, realname="Bitcoin monitoring bot https://github.com/davesteele/python-bitcoin-talk" ): SingleServerIRCBot.__init__(self, [(server, port)], nickname, realname) self.channel = channel self.txCallbacks = []
def __init__(self, channel, nickname, server, port=6667, password=None, learninterval=300): SingleServerIRCBot.__init__(self, [(server, port, password)], nickname, nickname) self.channel = channel self.start_prelude() self.time = time() self.learninterval = learninterval
def __init__(self, channels, nickname, nickpass, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.initial_channels = channels self.nickpass = nickpass # magic_key is used for admin commands. E.g., "magic_key say # test" in a query with the bot triggers the admin command # "say". self.magic_key = ''.join( [random.choice(string.ascii_letters) for x in range(8)]) + ' ' self.print_magic_key() self.current_topic = '' self._timers = [] self._connect()
def __init__(self, channel, nickname, password, server, port=6667): self.dcc_received = {} self.nickname = nickname self.password = password SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname, reconnection_interval=60) self.channel = channel self.conn = self.connection self.messages = [] self.log = Logger() self.start() self.connected_checker()
def __init__(self, channel, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel f = open("rules/versions.txt") for line in f: self.ruleversions.append(line.strip("\n")) f.close() f = open("users.txt") for line in f: self.powerusers.append(line.strip("\n")) f.close() f = open("points.txt") for line in f: user, points = line.strip("\n").split(" - ") self.points[user] = int(points) f.close()
def __init__(self, site, channel, nickname, server, port=6667, **kwargs): pywikibot.Bot.__init__(self, **kwargs) SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel self.site = site self.other_ns = re.compile( u'\x0314\\[\\[\x0307(%s)' % u'|'.join(item.custom_name for item in site.namespaces.values() if item != 0)) self.api_url = self.site.apipath() self.api_url += '?action=query&meta=siteinfo&siprop=statistics&format=xml' self.api_found = re.compile(r'articles="(.*?)"') self.re_edit = re.compile( r'^C14\[\[^C07(?P<page>.+?)^C14\]\]^C4 (?P<flags>.*?)^C10 ^C02' r'(?P<url>.+?)^C ^C5\*^C ^C03(?P<user>.+?)^C ^C5\*^C \(?^B?' r'(?P<bytes>[+-]?\d+?)^B?\) ^C10(?P<summary>.*)^C'.replace( '^B', '\002').replace('^C', '\003').replace('^U', '\037'))
def __init__(self, configs, join=True): """Initializes the bot.""" self.settings, self.terps, self.terp_exts = readconfig(configs, silent=False) if not self.terps: print("No interpreters specified in configuration. Add to {file}.". format(file=" ".join(configs))) sys.exit(1) SingleServerIRCBot.__init__( self, [[self.settings['server'], self.settings['port']]], self.settings['nickname'], self.settings['nickname']) self.immediate_join = join self.process = None self.thread = None self.lock = threading.Lock() self.buffer = []
def __init__(self, server, port, ssl=False, server_pass=None, channels=[], nick="timber", nick_pass=None, format=default_format): SingleServerIRCBot.__init__(self, [(server, port, ssl, server_pass)], nick, nick) self.chans = [x.lower() for x in channels] self.format = format self.set_ftp() self.count = 0 self.nick_pass = nick_pass self.load_channel_locations() print "Logbot %s" % __version__ print "Connecting to %s:%i..." % (server, port) print "Press Ctrl-C to quit"
def __init__(self, server, port, server_pass=None, channels=[], nick="pelux", nick_pass=None): SingleServerIRCBot.__init__(self, [(server, port, server_pass)], nick, nick) self.chans = [x.lower() for x in channels] self.set_ftp() self.nick_pass = nick_pass print "Logbot %s" % __version__ print "Connecting to %s:%i..." % (server, port) print "Press Ctrl-C to quit"
def __init__(self, channel, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname, 15) self.channel = channel self.doingcommand = False self.botnick = nickname self.commandaccesslist = {} self.commandcooldownlast = {} self.spam = {} self.load_config() print(self.loadmodules()) self.keepalive_nick = "OperServ" self.alive = True
def __init__(self, server, port, server_pass=None, channels=[], nick='timber', nick_pass=None, format=default_format): SingleServerIRCBot.__init__(self, [(server, port, server_pass)], nick, nick) self.chans = [x.lower() for x in channels] self.format = format self.nick_pass = nick_pass print 'Logbot %s' % __version__ print 'Connecting to %s:%i...' % (server, port) print 'Press Ctrl-C to quit'
def __init__(self, channel, nickname, server, port=6667): self.lastnick = nickname SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel.split(':')[0] if len(channel.split(':')) > 1: self.channelkey = channel.split(':')[1] else: self.channelkey = "" self.nextspeak = itime() self.lastsaid = [] self.lasttargeted = {} self.curtargets = {} self.timerRunning = 0 self.compositeBuffer = {} self.compositeTiming = {} self.intendedNickname = nickname self.lookuptable = { "calc": self.ParseModule("USER", "<key>", self.command_calc, helptext = "Prints out the requested calc message."), "apropos": self.ParseModule("USER", "<text>", self.command_apropos, helptext = "Searches both calc keys and values for the given text."), "aproposk": self.ParseModule("USER", "<text>", self.command_aproposk, helptext = "Searches calc keys for the given text."), "aproposv": self.ParseModule("USER", "<text>", self.command_aproposv, helptext = "Searches calc values for the given text."), "apropos2": self.ParseModule("USER", "[<text>]", self.command_apropos2, visible = False), # error only "status": self.ParseModule("USER", "[<key>]", self.command_status, helptext = "Shows bot status with no parameter, or calc information with a calc key.", confused_help = False), "help": self.ParseModule("USER", "[<command>]", self.command_help, helptext = "Irrevocably destroys the universe. Never use this.", confused_help = False), "more": self.ParseModule("USER", "", self.command_more, helptext = "Gives more output from commands that can generate more than a page.", confused_help = False), "version": self.ParseModule("USER", "<version> <key>", self.command_version, helptext = "Shows old versions of calcs.", confused_help = False), "owncalc": self.ParseModule("USER", "<key>", self.command_owncalc, helptext = "Tells you who last changed a calc."), "tell": self.ParseModule("PUBLIC", "<user> <key>", self.command_tell, helptext = "Sends a calc directly to a user in private msg.", parsechecker = self.command_tell_parsechecker, confused_help = False), "mkcalc": self.ParseModule("CHANGE", "<key> = <value>", self.command_mkcalc, helptext = "Creates a new calc."), "rmcalc": self.ParseModule("CHANGE", "<key>", self.command_rmcalc, helptext = "Removes an existing calc."), "chcalc": self.ParseModule("CHANGE", "<key> = <value>", self.command_chcalc, helptext = "Changes an existing calc."), "whois": self.ParseModule("GOD", "[<user>]", self.command_whois, helptext = "Shows hostmask info for a user.", private_only = True), "match": self.ParseModule("GOD", "<hostmask>", self.command_match, helptext = "Matches a given hostmask to a user ID.", private_only = True), "addhost": self.ParseModule("GOD", "<user> <hostmask>", self.command_addhost, helptext = "Adds a host for a user.", private_only = True), "rmhost": self.ParseModule("GOD", "[<user>] <hostmask>", self.command_rmhost, helptext = "Removes a host from a user (defaults to removing hosts from yourself.)", private_only = True), "chperm": self.ParseModule("GOD", "<user> <level>", self.command_chperm, helptext = "Changes permission level for someone. IGNORE = bot does not pay attention to the user. USER = normal private-only access. PUBLIC = can calc in public and send tells. CHANGE = can change, add, or remove calcs. AUTHORIZE = same as CHANGE, kind of obsolete. GOD = can change permission levels and add hostmasks.", private_only = True), } for value in self.lookuptable.itervalues(): value.setConfused(self.command_confused)