Permalink
Browse files

Moved a shitton of modules to the private namespace

  • Loading branch information...
1 parent c96f4d4 commit 6d3a9f6e6709b2f153bbaaa2b4d3d57d9dc93400 @richo committed Sep 24, 2011
Showing with 0 additions and 357 deletions.
  1. +0 −126 modules.d/basic24.py
  2. +0 −8 modules.d/douche.py
  3. +0 −13 modules.d/git.py
  4. +0 −29 modules.d/links.py
  5. +0 −12 modules.d/losty.py
  6. +0 −14 modules.d/penis.py
  7. +0 −86 modules.d/radio.py
  8. +0 −69 modules.d/remember.py
View
@@ -1,126 +0,0 @@
-
-# Begin HBH Basic24 code
-
-import hashlib
-import base64
-import binascii
-import logging
-import traceback
-class Basic24Module(BawtM2):
- success_re = re.compile(r"[\r\n]{1,2}\s+QUIT", re.I)
- _commands = ['help', 'say', 'md5', 'b64', 'sha1', 'rot47', 'hex', 'rot47crack', 'b64crack', 'hex2ascii' ]
- privmsg_re = "^@(%s)" % ("|".join(_commands))
- badchars = ["\r", "\n", "\t", chr(8) ]
- _name = "Basic24Module"
-
- def bind_write(self, msg):
- def write(text):
- success = False
- # Test for a solution
- if self.success_re.search(text):
- success = True
- # Scrub some badchars..
- for i in self.badchars:
- text = text.replace(i, '')
- # Prefix with nick..?
- if not success:
- self.parent.privmsg(msg.replyto, "%(nick)s: %(text)s" % {'nick': msg.nick,
- 'text': text })
- else:
- self.parent.privmsg(msg.nick, "%(nick)s: Well done, the password is... crlfOwnsYou" % {'nick': msg.nick})
- self.write = write
-
- @staticmethod
- def rot47(text):
- return ''.join([chr(33+((ord(c)-33+47)\
- %(47*2))) if c!=" "else " " for c in text])
-
- def handle_privmsg(self, msg):
- try:
- self.real_handle_privmsg(msg)
- except Exception as exc:
- logging.error("Fell on it's arse with %s" % (msg.dump))
- #traceback.print_exception(*exc.args, file=logging.Writer(logging.error))
- raise
-
- def real_handle_privmsg(self, msg):
- self.bind_write(msg)
- argv = msg.data_segment.split(" ", 1)
- try:
- # {{{ Handle arguments, delegate calls
- if argv[0] == "@help":
- self.do_help()
- else:
- try:
- # Needs to be a PM...
- if msg.replyto.startswith("#"):
- self.write("You must play with the bot in pm's....")
- return
- if argv[0] == "@say":
- self.do_say(argv[1])
- elif argv[0] == "@md5":
- self.do_md5(argv[1])
- elif argv[0] == "@b64":
- self.do_b64(argv[1])
- elif argv[0] == "@sha1":
- self.do_sha1(argv[1])
- elif argv[0] == "@rot47":
- self.do_rot47(argv[1])
- elif argv[0] == "@hex":
- self.do_hex(argv[1])
- #elif argv[0] == "@md5crack":
- # self.do_md5crack(argv[1])
- elif argv[0] == "@b64crack":
- self.do_b64crack(argv[1])
- #elif argv[0] == "@sha1crack":
- # self.do_sha1crack(argv[1])
- elif argv[0] == "@rot47crack":
- self.do_rot47crack(argv[1])
- elif argv[0] == "@hex2ascii":
- self.do_hex2ascii(argv[1])
- else:
- self.write("How on earth did you get here")
- # }}}
- except IndexError:
- raise
- except:
- logging.error(msg.dump())
- except IndexError:
- self.write("That function requires an argument...")
- def do_help(self):
- helpstr = []
- for i in self._commands:
- helpstr.append("@"+i)
- self.write(", ".join(helpstr))
- self.write("Remember, the objective is to cause the bot to disconnect from the irc network")
- def do_say(self, text):
- self.write(text)
- def do_md5(self, text):
- self.write(hashlib.md5(text).hexdigest())
- def do_b64(self, text):
- self.write(base64.b64encode(text))
- def do_sha1(self, text):
- self.write(hashlib.sha1(text).hexdigest())
- def do_rot47(self, text):
- self.write(self.rot47(text))
- def do_hex(self, text):
- outs = ""
- for i in text:
- outs += "%x" % ord(i)
- self.write(outs)
- #def do_md5crack(self, text):
- # self.write("md5crack")
- def do_b64crack(self, text):
- try:
- self.write(base64.b64decode(text))
- except TypeError:
- self.write("Invalid b64 data")
- #def do_sha1crack(self, text):
- # self.write("sha1crack")
- def do_rot47crack(self, text):
- self.write(self.rot47(text))
- def do_hex2ascii(self, text):
- try:
- self.write(binascii.unhexlify(text))
- except TypeError:
- self.write("Invalid hex data")
View
@@ -1,8 +0,0 @@
-class DoucheModule(BawtM2):
- privmsg_re = "!douche"
- _name = "DoucheModule"
- def handle_privmsg(self, msg):
- args = msg.data_segment.split(" ")
- if len(args) > 1:
- self.parent.privmsg(msg.replyto, "%s: Stop being a douche" % (args[1]))
-
View
@@ -1,13 +0,0 @@
-import ourgit
-
-class GitModule(BawtM2):
- """A pyBawt frontend to git."""
- _name = "GitModule"
- privmsg_re = "^(!|%(nick)s:\s+)git ?([^ ].*)"
- def handle_privmsg(self, msg):
- if self.auth(msg):
- cmd = 'git ' + self.m.group(2)
- if cmd:
- self.parent.privmsg(msg.replyto, ourgit.oneline(cmd))
- else:
- self.parent.privmsg(msg.replyto, "You are not authenticated")
View
@@ -1,29 +0,0 @@
-# TODO Add some data directory in the next level up, and have the same
-# mechanism that buidls everything in modules.d include it first, then put
-# module data in there, to avoid this nasty mix of code and data in the module
-# code.
-#
-# This should make it more feasible for 3rd party developers to use this, and
-# may also motivate me to finally build a usable authentication layer
-
-class LinkModule(BawtM2):
- "Translate links neatly"
- trips = ['!nat']
- # TODO Create a user class to hold all of this data along with GH repo etc
- usermap = {'richo': ('richo', 'rich0', 'warlawk', 'warl0ck'),
- 'samurai': ('drewid', 'samurai', 'drewid[rogue]',
- 'drewid[nat]', 'TheLonelyPanda'),
- 'carbon': ('CarbonLifeForm', 'm0nk')}
- # ^^ todo
- privmsg_re = "^(%(t)s) (.*)" % {'t': '|'.join(trips)}
- _name = "LinkModule"
- def handle_privmsg(self, msg):
- for user, nicks in self.usermap.iteritems():
- if msg.nick in nicks:
- self.parent.privmsg(msg.replyto, "http://natalya.psych0tik.net/~%s/%s" %
- (user, self.m.group(2)))
- return
- self.parent.privmsg(msg.replyto, "%s: I'm fairly sure you don't have an account on natalya" % (msg.nick))
-
-
-
View
@@ -1,12 +0,0 @@
-class LostyModule(BawtM2):
- privmsg_re = "losty"
- _name = "LostyModule"
- def handle_privmsg(self, msg):
- self.parent.privmsg(msg.replyto, "Losty is a raging faggot")
-
-class BlipModule(BawtM2):
- privmsg_re = "blip"
- privmsg_flags = re.I
- _name = "BlipModule"
- def handle_privmsg(self, msg):
- self.parent.kick(msg.replyto, msg.nick, "I'll fucken blip you in a moment")
View
@@ -1,14 +0,0 @@
-import time
-import random
-
-class PenisModule(BawtM2):
- "8======D"
- timeout = 60
- timelast = None
- privmsg_re = "^!penis"
- _name = "PenisModule"
- def handle_privmsg(self, msg):
- if self.timelast and time.time() < (self.timelast + self.timeout):
- return
- self.timelast = time.time()
- self.parent.privmsg(msg.replyto, "%s: 8====%s====D" % (msg.nick, "="*random.randint(4,10)))
View
@@ -1,86 +0,0 @@
-import mpd
-import signal
-
-class RadioModule(BawtM2):
- """Houses everything to do with the radio"""
- _commands = ['current', 'url', 'something']
- topic_re = "."
- privmsg_re = "^(!|%(nick)s:\s?)(%(commands)s)" % {'commands': "|".join(_commands),
- 'nick': '%(nick)s'}
- _name = "RadioModule"
- def __init__(self, parent, channel):
- # Overloaded to allow us to bind our signal
- BawtM2.__init__(self, parent, channel)
-
- parent.reg_handler(signal.SIGALRM, self.update_song)
- # This is not the place to be doing misc channel specfic stuff like
- # getting ops. Put this in channel.py. Or something. Even if it just
- # means calling a func that's defined here, from there.
-
- self.topic_prefix = "psych0tik radio"
- self.topic_suffix = "http://radio.psych0tik.net/FAQ.py"
-
-
- def update_song(self):
- topic = "%s || %s || %s" % (self.topic_prefix, self.str_current_song(), self.topic_suffix)
- if not self.channel.set_topic(topic):
- self.channel.privmsg("Dammit I needz teh ops!")
-
- def str_current_song(self):
- reply = "Now playing %(title)s by %(artist)s"
- return reply % self.current_song()
-
- def current_song(self):
- blank = { 'album': 'Unknown Album', #{{{ Blank template data
- 'composer': 'Unknown Compose',
- 'artist': 'Unknown Artist',
- 'track': '0',
- 'title': 'Unknown Track',
- 'pos': '0',
- 'last-modified': 'Unknown Date',
- 'albumartist': 'Unknown Artist',
- 'file': 'Unknown File',
- 'time': '0',
- 'date': 'Unknown Date',
- 'genre': 'Unknown Genre',
- 'id': '0'} #}}}
- client = mpd.MPDClient()
- client.connect("domino.psych0tik.net", 6600)
- data = client.currentsong()
- client.close()
- client.disconnect()
- blank.update(data)
- return blank
-
- def handle_topic(self, msg):
- """This will get confused if there aren't two sets of || in the topic
- So we just drop it if that happens"""
- # Radio topic updating disabled until radio comes back up
- return
- if msg.nick == self.parent.nick:
- # Otherwise we'll be here all day.
- return
- new = msg.data_segment
- if new.count("||") < 2:
- self.parent.privmsg(msg.address_segment, "%s: Sorry, you must include the || markers in the topic" % msg.nick)
- else:
- self.topic_prefix, song, self.topic_suffix = new.split("||", 2)
- self.topic_prefix, self.topic_suffix = self.topic_prefix.strip(), self.topic_suffix.strip()
- self.update_song()
-
-
- def handle_privmsg(self, msg):
- # TODO - Put checking this in the event cue somehow?
- # TODO - Timeout on connections
- if self.m.group(2) == "url":
- self.parent.privmsg(msg.replyto, "%s: http://radio.psych0tik.net/hax.ogg.m3u" % (msg.nick))
-
- elif self.m.group(2) == "current":
- reply = "Now playing %(title)s by %(artist)s off %(album)s" % self.current_song()
- self.parent.privmsg(msg.replyto, "%s: %s" % (msg.nick, reply))
-
-# TODO
-# commands:
-# url last10 last5
-# next?
-# Some degree of admin control
View
@@ -1,69 +0,0 @@
-import webutils as wb
-
-class Notes(object):
- def __init__(self, note_file):
- self.note_file = note_file
-
- def __enter__(self):
- try:
- self.out = []
- for i in open(self.note_file, 'r').readlines():
- line = i.replace("\r", "").replace("\n", "")
- self.out.append(line)
- return self.out
- except IOError:
- return []
- def __exit__(self, type, value, traceback):
- fh = open(self.note_file, 'w')
- for i in self.out:
- fh.write(i + '\n')
-
-
-class NoteModule(BawtM2):
- """A module for the storage and retrieval of notes"""
- _name = "NoteModule"
- _commands = ['store', 'clear', 'list']
- privmsg_re = "^(!|%(nick)s:\s?)(%(commands)s)" % {'commands': "|".join(_commands),
- 'nick': '%(nick)s'}
- note_file = "note_data_%s"
-
- def reply(self, msg, say):
- self.parent.privmsg(msg.replyto, "%s: %s" % (msg.nick, say))
-
- def handle_privmsg(self, msg):
- if self.auth(msg):
- limit = 5000
- else:
- limit = 25
- with Notes(self.note_file % msg.nick) as notes:
- argv = msg.data_segment.split(" ")
- if self.m.group(2) == "store":
- if len(notes) > limit:
- self.reply("Too many notes stored")
- return
- note = " ".join(argv[1:])
- if len(note) > 256:
- self.reply("Note too long")
- return
- if note:
- if note in notes:
- self.reply(msg, "Message already stored")
- else:
- notes.append(note)
- self.reply(msg, "Stored.")
- else:
- self.reply(msg, "!store <note>")
- elif self.m.group(2) == "clear":
- while notes:
- del notes[0]
- self.reply(msg, "Message list cleared.")
- elif self.m.group(2) == "list":
- if not notes:
- self.reply(msg, "I pity the fool who has no notes")
- return
- try:
- note_data = "\n".join(notes)
- self.reply(msg, wb.publish(note_data))
- except wb.PublicationError:
- self.reply(msg, "Couldn't publish note data")
-

0 comments on commit 6d3a9f6

Please sign in to comment.