Advertisement
Guest User

Untitled

a guest
Aug 6th, 2012
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.04 KB | None | 0 0
  1. #stuff.py:
  2.  
  3. import os
  4. import commands
  5. import random
  6. import re
  7. import sys
  8. if 'torqux' not in sys._getframe().f_back.f_code.co_filename:
  9.     lol_no
  10. helpDict = {'messages': 'usage: "!messages [who] [message]".  Save messages for someone for the next time they join',
  11.  'action': 'usage: "!action [action]"',
  12.  'dance': 'usage: "!dance"',
  13.  'dice': 'usage: !dice [number]',
  14.  'echo': 'usage: "!echo [message]"',
  15.  'fortune': 'usage: "!fortune"',
  16.  '8ball': 'usage: "!8ball"',
  17.  'highfive': 'usage: "!highfive"',
  18.  'god': 'usage: "!god".  Display some ascii art',
  19.  'stab': 'usage: "!stab [x]"',
  20.  'vuvuzela': 'usage "!vuvuzela"',
  21.  'sheep': 'usage "!sheep [nick]"'}
  22. _eightballResponses = ['As I see it, yes',
  23.  'It is certain',
  24.  'It is decidedly so',
  25.  'Most likely',
  26.  'Outlook good',
  27.  'Signs point to yes',
  28.  'Without a doubt',
  29.  'Yes',
  30.  'Yes - definitely',
  31.  'You may rely on it',
  32.  'Reply hazy, try again',
  33.  'Ask again later',
  34.  'Better not tell you now',
  35.  'Cannot predict now',
  36.  'Concentrate and ask again',
  37.  "Don't count on it",
  38.  'My reply is no',
  39.  'My sources say no',
  40.  'Outlook not so good',
  41.  'Very doubtful']
  42. mohammeds = ['Muhammad (((:~{>',
  43.  'Pirate Muhammad (((P~{>',
  44.  'Cool Muhammad (((B~{>',
  45.  'Insurgent Mohammad *-O)):~{>',
  46.  'Angry Muhammad (((B-|>',
  47.  'Rich Muhammad (($$(((:~{>',
  48.  'Cranky Muhammad ((((;~{[>']
  49. peopleIknow = []
  50.  
  51. def _addit(bot, name, reason, extra):
  52.     bot.config['modules'].append(extra)
  53.  
  54.  
  55.  
  56. def _makeit(bot, user, target, argument):
  57.     bot.config['admins'][user] = int(argument)
  58.     print repr(bot.config)
  59.  
  60.  
  61.  
  62. def idle(bot, data):
  63.     user = re.findall('\\A\\:([^\\!]+)[^ ]+ JOIN \\:#', data)
  64.     if user and user[0] not in bot.config['ignore']:
  65.         if os.path.isfile(user[0]):
  66.             with open(user[0], 'r') as myfile:
  67.                 messages = map(lambda s: s.strip(), myfile.readlines())
  68.                 print 'MESSAGES',
  69.                 print repr(messages)
  70.                 bot.sendLns(user[0], messages)
  71.             os.remove(user[0])
  72.         if user[0] in peopleIknow:
  73.             peopleIknow.append(user[0])
  74.  
  75.  
  76.  
  77. def eightBall(bot, user, target, argument):
  78.     bot.sendLns(target, _eightballResponses[random.randint(0, 19)])
  79.  
  80.  
  81.  
  82. def about(bot, user, target, argument):
  83.     lines = bot.config['about'].split('\\n')
  84.     bot.sendLns(user, lines)
  85.  
  86.  
  87.  
  88. def action(bot, user, target, argument):
  89.     bot.sendLns(bot.config['channel'], '\x01ACTION ' + argument + '\x01')
  90.  
  91.  
  92.  
  93. def d(bot, user, target, argument = '6'):
  94.     size = 6
  95.     try:
  96.         size = int(argument)
  97.     except:
  98.         pass
  99.     number = random.randint(1, size)
  100.     action(bot, '', '', 'rolls a %d sided die.  got %d' % (size, number))
  101.  
  102.  
  103.  
  104. def dance(bot, user, target, argument):
  105.     action(bot, '', '', 'dances :D--<')
  106.     action(bot, '', '', 'dances :D|-<')
  107.     action(bot, '', '', 'dances :D/-<')
  108.  
  109.  
  110.  
  111. def echo(bot, user, target, argument):
  112.     bot.sendLns(bot.config['channel'], argument)
  113.  
  114.  
  115.  
  116. def fortune(bot, user, target, argument):
  117.     fortune = commands.getoutput('fortune -as')
  118.     fortune = re.split('\n', fortune)
  119.     bot.sendLns(target, fortune)
  120.  
  121.  
  122.  
  123. def help(bot, user, target, argument):
  124.     argument = argument.replace('!', '')
  125.     if argument in helpDict:
  126.         response = helpDict[argument].replace('<me>', bot.config['botName'])
  127.     elif argument:
  128.         response = "Command '" + argument + "' not found in help file."
  129.     else:
  130.         response = 'usage: !help [command].'
  131.     keys = helpDict.keys()
  132.     keys.sort()
  133.     response = [response, 'List of commands: !' + ' !'.join(keys)]
  134.     bot.sendLns(user, response)
  135.  
  136.  
  137.  
  138. def highfive(bot, user, target, argument):
  139.     bot.sendLns(target, '\x01ACTION high fives ' + user + '.\x01')
  140.  
  141.  
  142.  
  143. def kick(bot, user, target, argument):
  144.     bot.sendRaw('KICK ' + bot.config['channel'] + ' ' + argument + '\r\n')
  145.  
  146.  
  147.  
  148. def kill(bot, user, target, argument):
  149.     action(bot, '', '', 'dies.')
  150.  
  151.  
  152.  
  153. def god(bot, user, target, argument):
  154.     bot.sendLns(target, mohammeds[random.randint(0, len(mohammeds) - 1)])
  155.  
  156.  
  157.  
  158. def nick(bot, user, target, argument):
  159.     bot.sendRaw('NICK ' + argument + '\r\n')
  160.     bot.config['botName'] = argument
  161.  
  162.  
  163.  
  164. def messages(bot, user, target, argument):
  165.     message = argument.split(' ')
  166.     who = message[0]
  167.     message = ' '.join(message[1:])
  168.     with open(who, 'a') as myfile:
  169.         myfile.write(message + '\n')
  170.     action(bot, user, '', 'saved the message "%s" for %s' % (message, who))
  171.  
  172.  
  173.  
  174. def stab(bot, user, target, argument):
  175.     action(bot, '', '', 'stabs ' + argument)
  176.  
  177.  
  178.  
  179. def vuvuzela(bot, user, target, argument):
  180.     bot.sendLns(target, '\x02BZZZZZZZZZZZZZZZZZ BZZZZZ BZZZZZ BZZZZZ BZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZz\x02')
  181.  
  182.  
  183.  
  184. def sheep(bot, user, target, argument):
  185.     messages = ['x likes to fuck sheep.', "sheep lick x's balls", 'x wishes sheep liked him']
  186.     args = re.findall('-([a-zA])\\W+(.*)', argument)
  187.     if len(args):
  188.         (flag, thing,) = args[0]
  189.     else:
  190.         (flag, thing,) = ('d', argument)
  191.     bot.sendLns(target, messages[random.randint(0, len(messages))].replace('x', thing))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement