Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Wei En wei2912
file 42 lines (36 sloc) 1.219 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
import pyrc
import pyrc.utils.hooks as hooks

class GangstaBot(pyrc.Bot):
  @hooks.command()
  def info(self, target, sender):
    "will print the target and sender to the console"
    print("target: %s, sender: %s" % (target, sender))

  @hooks.command()
  def bling(self, target, sender):
    "will print yo"
    if target.startswith("#"):
      self.message(target, "%s: yo" % sender)
    else:
      self.message(sender, "yo")

  @hooks.command("^repeat\s+(?P<msg>.+)$")
  def repeat(self, target, sender, **kwargs):
    "will repeat whatever yo say"
    if target.startswith("#"):
      self.message(target, kwargs["msg"])
    else:
      self.message(sender, kwargs["msg"])

  @hooks.privmsg("(lol|lmao|rofl(?:mao)?)")
  def stopword(self, target, sender, *args):
    """
will repeat 'lol', 'lmao, 'rofl' or 'roflmao' when seen in a message
only applies to channel messages
"""
    if target.startswith("#"):
      self.message(target, args[0])

  @hooks.interval(10000)
  def keeprepeating(self):
    "will say something"
    self.message("#turntechgodhead", "stop repeating myself")

if __name__ == '__main__':
  bot = GangstaBot('irc.freenode.net', channels = ['#turntechgodhead'])
  bot.connect()
Something went wrong with that request. Please try again.