Пример #1
0
      return f**e    
    if split[0]=="fibonacci":
      a = [0, 1]
      tgt = int(split[1])
      v = 0
      while tgt >= 2:
        v = a[0] + a[1]
        a[0] = a[1]
        a[1] = v
        tgt -= 1
      return v


if __name__ == '__main__':
  import sys
  c = IRCBot(sys.argv[1], verbosity=True)
  def exampleexitcallback(user, host, dest, mesg):
    if (user == 'ChloeD'):
      print("Oh, hello ChloeD")
      c.send_chat("#bottest", "I'm leaving now")
      c.disconnect()
      sys.exit(0)
  c.add_privmsg_callback(re.compile("!exit"), exampleexitcallback)
  bot = Botsync(c, "#bottest")
  bot.add_work_executor(StupidMathsWorker())
  t1 = Thread(target=lambda:c.connect("irc.freenode.net", 6667, "#bottest"))
  t2 = Thread(target=bot.schedule_start)
  t1.start()
  t2.start()
  [ x.join() for x in [ t1, t2 ] ]