A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. # Actions/commands to interface with IRC.
  3. class Actions:
  4. def __init__(self, sock):
  5. """actions/commands to interface with IRC"""
  6. self.sock = sock
  7. def send(self, msg):
  8. """send data to the server"""
  9. self.sock.send(msg + "\r\n")
  10. print " %s" % msg
  11. def say(self, target, msg):
  12. """send a message"""
  13. self.send("PRIVMSG %s :%s" % (target, msg))
  14. def action(self, target, msg):
  15. """send a message as an action"""
  16. self.say(target,"%sACTION %s%s" % (chr(1), msg, chr(1)))
  17. def notice(self, target, msg):
  18. """send a notice"""
  19. self.send("NOTICE %s :%s" % (target, msg))
  20. def join(self, chan):
  21. """join a channel"""
  22. self.send("JOIN %s" % chan)