from pybot import Pybot from os import mkdir from os import popen import logging import logging.handlers import re HOST = "localhost" CHANNELS = ["#somechannel"] BOTNICK = "logbot" p = Pybot(HOST, nick='logbot') p.join(CHANNELS) LOG = True MAIL_HOST = '' FROM_ADDR = '' TO_ADDR = '' SUBJECT = '' MAIL_ADMINS = ['*****@*****.**'] class Logger(dict): """docstring for Logger""" def __init__(self, system_name): super(Logger, self).__init__() self.system_name = str(system_name) try: mkdir('log') except OSError:
from pybot import Pybot import smtplib from email.mime.text import MIMEText from twitter import Twitter, OAuth HOST = "localhost" CHANNELS = ["#somechannel"] p = Pybot(HOST, nick='twitbot') p.join(CHANNELS) CONSUMER_KEY = 'V' CONSUMER_SECRET = 'X' ACCESS_KEY = 'Y' ACCESS_SECRET = 'Z' twitter = Twitter(auth=OAuth(ACCESS_KEY, ACCESS_SECRET, CONSUMER_KEY, CONSUMER_SECRET)) while True: for msg in p.fetch(): if msg.channel in CHANNELS and msg.content.find("status") != -1 and msg.content.find("twitbot:") != -1: statuses = twitter.statuses.friends_timeline(id="twitbot_") email_text = '' matrix = {} for s in statuses: if matrix.has_key(s['user']['screen_name']) is False: matrix[s['user']['screen_name']] = s['text'] for u in matrix: email_text += u + ':\t ' + matrix[u] + '\n\n'
from pybot import Pybot p = Pybot("comm.secretsite.com", nick="dumbot") p.join("#secretchannel") while True: p.say("#secretchannel", "haha, can't catch me")
from pybot import Pybot HOST = "comm.secretsite.com" CHANNELS = ["#pcilevelonecompliant", "#pcileveltwocompliant", "#general"] p = Pybot(HOST, nick="todobot") p.join("#general") #create a new pybot : Pybot(hostname, port=394024, nick='somenick' #tell pybot to join a channel: p.join("#channelname") #fetch available messages : p.fetch() ----> [msg, msg, msg, msg] #say something in a particular channel : p.say("#channelgoeshere", "thing to say goes here") FILENAME = 'todobot.data' class TodoList: def __init__(self): self.file = open(FILENAME, 'r') items = self.file.readlines() if len(items) > 0: self.items = [f.rstrip() for f in items] else: self.items = [] self.file.close() def save(self): self.file = open(FILENAME, 'w') for i in self.items: print >>self.file, i self.file.close()
from pybot import Pybot from os import mkdir import logging import logging.handlers import re HOST = "localhost" CHANNELS = ["#somechannel"] BOTNICK = "timebot" p = Pybot(HOST, nick=BOTNICK) p.join(CHANNELS) p.say(CHANNELS, "%s reporting for duty!" % BOTNICK) from datetime import datetime, timedelta from pytz import timezone import pytz utc = pytz.utc est = timezone('US/Eastern') pst = timezone('US/Pacific') jhb = timezone('Africa/Johannesburg') zones = [pst, est, utc, jhb] fmt = '%H:%M:%S %Z%z' while True: for msg in p.fetch(): if msg.channel in CHANNELS: if re.search("%s:" % BOTNICK, msg.content):
from pybot import Pybot HOST = "comm.secretsite.com" CHANNELS = ["#pcilevelonecompliant", "#pcileveltwocompliant"] p = Pybot(HOST) p.join(CHANNELS) while True: for msg in p.fetch(): if msg.channel in CHANNELS: #someone said something in our channel, echo it back p.say(CHANNELS, "user [%s] just said message[%s] in channel[%s]" % (msg.user, repr(msg.content), msg.channel))