Пример #1
0
    for h in self.handlers:
      new_logger.addHandler(h)

    self[logname] = new_logger

  def add_logger(self, logname, logger):
    logger.setLevel(logging.DEBUG)

    for h in self.handlers:
      logger.addHandler(h)

    self[logname] = logger

log = Logger('logbot')

p.say(CHANNELS, "logbot reporting for duty!")

while True:
  for msg in p.fetch():
    if msg.channel in CHANNELS:
      if re.search('%s:' % BOTNICK, msg.content, flags=re.IGNORECASE):

        if re.search('mode', msg.content, flags=re.IGNORECASE):
          if LOG is True:
            p.say(msg.channel, "watching your every move...")
          else:
            p.say(msg.channel, "turning a blind eye...")
          continue

        elif re.search('public', msg.content, flags=re.IGNORECASE):
          LOG = True
Пример #2
0
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'
        p.say(msg.channel, u + ': ' + matrix[u])

      email = MIMEText(email_text)
      email['Subject'] = 'twitbot reporting for duty'
      email['From'] = '*****@*****.**'
      email['To'] = '*****@*****.**'
      s = smtplib.SMTP('mail.authsmtp.com', 2525)
      s.login(USER, PASS)
      s.sendmail('*****@*****.**', ['*****@*****.**'], email.as_string())
      s.quit()
Пример #3
0
from pybot import Pybot

p = Pybot("comm.secretsite.com", nick="dumbot")
p.join("#secretchannel")

while True:
    p.say("#secretchannel", "haha, can't catch me")
Пример #4
0
    self.save()

todo = TodoList()

while True:
  for msg in p.fetch():
    #msg is an object that represents a single user's message sent to the server
    #msg.channel
    #msg.content
    #msg.user

    if msg.channel in CHANNELS:
      if msg.content.find("todobot:") != -1:

        if msg.content.find("list") != -1:
          p.say(msg.channel, "Todo list:")
          for i,thing in enumerate(todo.items):
            p.say(msg.channel, "%d: %s" % (i,thing))

        elif msg.content.find("add") != -1:
          index_of_add_cmd = msg.content.find("add ")
          thing_to_add = msg.content[index_of_add_cmd + len("add "):]
          todo.add(thing_to_add)

          p.say(msg.channel,"Added item %s" % thing_to_add)

        elif msg.content.find("done") != -1:
          number = -1
          try:
            number = int(msg.content.split("done ")[1].rstrip())
            item = todo.items[number]
Пример #5
0
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):
Пример #6
0
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))