A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

Actions.py 786 B

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)