#!/usr/bin/python # Ircbot for pinging. import ircbot, time, urlbot3, silencer, reminderbot, quotebot, evalbot server = ("192.168.1.42", 6667) nick = "testbot" channels = ["#test"] bot = ircbot.Bot(nick=nick, channels=channels) def stats(m, origin, args, text, bot=bot): bot.safeMsg(origin.sender, bot.pingstats.stats(m.group(1)).split("\n")) def invite(m, origin, args, text, bot=bot): chan = text if chan in bot.channels: bot.todo(['JOIN', chan]) def leave(m, origin, args, text, bot=bot): bot.todo(['QUIT'], "bye bye!") bot.rule(invite, 'invite', cmd="INVITE") bot.rule(leave, 'leave', cmd="KICK") urlbot3.init_bot(bot) silencer.init_bot(bot)
def debug(*args): debuglog.write("%s: " % (time.asctime())) for a in args: debuglog.write(str(a)) debuglog.write("\n") debuglog.flush() ircbot.debug = debug server = ("irc.kolumbus.fi", 6667) nick = "jaubot" name = "Bot by Juha Autero <*****@*****.**>" channels = ["#espoohacklab"] bot = ircbot.Bot(nick=nick, channels=channels, name=name) bot.restart = 0 def invite(m, origin, args, text, bot=bot): chan = text if chan in bot.channels: bot.todo(['JOIN', chan]) def leave(m, origin, args, text, bot=bot): if text == "restart": bot.restart = 1 bot.todo(['QUIT'], "bye bye!")
self.addtext = 0 self.blog = blog self.title = title def add_text(self, text): if self.addtext: self.text.append(text) else: self.addtext = 1 def post(self): entrydict = {'subject': self.title, 'content': self.text} self.blog.post(entrydict) bot = ircbot.Bot(nick=botconfig.botnick, channels=botconfig.botchannels) bot.openentries = {} def blogaa(m, origin, args, text, bot=bot): blogname = m.group(1) blogtitle = m.group(2) print "blogaa blogiin %s otsikolla %s" % (blogname, blogtitle) if botconfig.blogs.has_key(blogname): bot.openentries[origin.nick] = Entry(botconfig.blogs[blogname], blogtitle) print bot.openentries def postaa(m, origin, args, text, bot=bot): print "Postaa"
self.wfile.write('<message>%s</message>' % msg, ) else: self.wfile.write('<error>0</error>\n') self.wfile.write('</response>\n') def bot_handle_ping(server, title, url): try: for channel in server.bot.channels: server.bot.msg(channel, server.bot.blogmessage, { 'title': title, 'url': url }) except Exception: return 0 return 1 if __name__ == "__main__": bot = ircbot.Bot(nick="pingbot", channels=["#test"]) def bye(m, origin, args, text, bot=bot): bot.todo(['QUIT'], "bye bye!") bot.rule(bye, 'bye', r'bye bye bot') server = asynchttpd.Server('localhost', 8080, PingRequestHandler) server.bot = bot server.blogmessage = "New blogentry: %(title)s, %(url)s" server.pinghandlers = {'irc': bot_handle_ping} bot.run("localhost", 6667)