Commits

Chris Mulligan  committed 0fbc4b7

Migrating some remaining YG stuff, improving the @contains deco

  • Participants
  • Parent commits c00dcdf

Comments (0)

Files changed (6)

       linkurl : "http://search.twitter.com/search?q=pmxbot"
       url     : "http://search.twitter.com/search.atom?q=pmxbot"
 local_extensions: ['local.py']
+librarypaste: http://a.libpa.st/
 web_port: 8080
 web_host: 0.0.0.0

File pmxbot/botbase.py

 					traceback.print_exc()
 				break
 			elif typ in('contains', '#') and name in lc_msg:
-				if (channels and channel in channels) \
-				and (exclude and channel not in exclude) \
-				and (rate == 1.0 or random.random() <= rate):
+				if channels and (channel not in channels \
+				or (channels == "logged" and channel in self._nolog) \
+				or (channels == "unlogged" and channel not in self._nolog)):
+					continue
+				if exclude and (channel not in exclude \
+				or (exclude == "logged" and channel in self._nolog) \
+				or (exclude == "unlogged" and channel not in self._nolog)):
+					continue
+				if random.random() <= rate:
 					try:
 						res = f(c, e, channel, nick, msg)
 					except Exception, e:

File pmxbot/pmxbot.py

 	return translation
 
 
-@command("boo", aliases=("b"), doc="Boo someone")
+@command("boo", doc="Boo someone")
 def boo(client, event, channel, nick, rest):
 	slapee = rest
 	karmaChange(botbase.logger.db, slapee, -1)
 	karmaChange(botbase.logger.db, keelee, -1)
 	return "/me straps %s to a dirty rope, tosses 'em overboard and pulls with great speed. Yarrr!" % keelee
 
-@command("annoy", aliases=("a",), doc="Annoy everyone with meaningless banter")
+@command("annoy", aliases=("a", "bother",), doc="Annoy everyone with meaningless banter")
 def annoy(client, event, channel, nick, rest):
 	def a1():
 		yield 'OOOOOOOHHH, WHAT DO YOU DO WITH A DRUNKEN SAILOR'
 	yield 'O-<-<'
 	yield 'O->-<'
 	yield 'AAAAAAAHHHH!!!  HEAD FOR THE HILLS!'
+	
+@command("duck", aliases=("ducky",), doc="Display a helpful duck")
+def duck(client, event, channel, nick, rest):
+	yield '__("<'
+	yield '\__/'
+	yield ' ^^'
 
 @command("rubberstamp",  aliases=('approve',), doc="Approve something")
 def rubberstamp(client, event, channel, nick, rest):
 	qt = bartletts(popular_quote_db, 'anchorman', nick, rest)
 	if qt:	return qt
 
+@command('hangover', aliases=(), doc='Quote hangover.')
+def hangover(client, event, channel, nick, rest):
+	qt = bartletts(popular_quote_db, 'hangover', nick, rest)
+	if qt:	return qt
+
+@command('R', aliases=('r',), doc='Quote the R mailing list')
+def R(client, event, channel, nick, rest):
+	qt = bartletts(popular_quote_db, 'R', nick, rest)
+	if qt:	return qt
+
 #Added quotes
 @command('quote', aliases=('q',), doc='If passed with nothing then get a random quote. If passed with some string then search for that. If prepended with "add:" then add it to the db, eg "!quote add: drivers: I only work here because of pmxbot!"')
 def quote(client, event, channel, nick, rest):
 	else:
 		r = channel
 	return '''you're "doing" "good" "work", %s!''' % r
+	
+@command("nailedit", aliases=("nail", "n"), doc="Nail that interview")
+def nailedit(client, event, channel, nick, rest):
+	random.shuffle(interview_excuses)
+	yield "Sorry, but " + interview_excuses[0]
+	yield("/me Nailed it!")
+
 
 @command("demotivate", aliases=("dm",), doc="Demotivate someone")
 def demotivate(client, event, channel, nick, rest):
 	else:
 		yield "I blame %s for everything!  it's your fault!  it's all your fault!!" % blamee
 		yield "/me cries and weeps in despair"
+		
+@command("paste", aliases=(), doc="Drop a link to your latest paste on %s" % config.librarypaste)
+def paste(client, event, channel, nick, rest):
+	post_url = browser.catch_redirect_url("%s/last/%s" % (config.librarypaste, nick))
+	if post_url:
+		return post_url
+	else:
+		return "hmm.. I didn't find a recent paste of yours, %s. Checkout %s" % (nick, config.librarypaste)
 
 @contains('pmxbot')
 def rand_bot(client, event, channel, nick, rest):
 	@contains(config.bot_nickname)
 	def rand_bot2(*args):
 		return rand_bot(*args)
-	
+
     for extension in config.local_extensions:
         print "Loading", extension
         execfile(extension)

File pmxbot/popquotes.sqlite

Binary file modified.

File pmxbot/saysomething.py

 			yield '\n'
 	yield '\n'
 
-def words_from_db(db):
+def words_from_db(db, max=100000):
 	db.text_factory = str
-	WORDS_SQL = '''SELECT message FROM logs UNION SELECT quote FROM quotes where library = 'pmx' '''
+	WORDS_SQL = '''SELECT message FROM logs order by random() limit %s''' % max
 	lines = db.execute(WORDS_SQL)
-	for line in lines:
+	QUOTE_SQL = '''SELECT quote FROM quotes where library = 'pmx''''
+	quotes = db.execute(QUOTE_SQL) 
+	for line in lines + quotes:
 		words = line[0].strip().lower().split()
 		for word in words:
 			yield word

File pmxbot/util.py

 	"%(a)s is sorry or something.",
 ]
 
+interview_excuses = [
+	"I need to go to the Dentist",
+	"I have a Doctor's appointment",
+	"my little brother got his arm stuck in the microwave, and my mom had to take him to the hospital and my grandma freaked out and dropped acid and hijacked a busload of penguins, so it's kind of a family crisis.",
+	"I need to go car shopping",
+	"I have an appointment with an attorney to make a will",
+	"my grandmother's funeral is today",
+	"I need to go to the DMV",
+	"I have a terrible case of diarrhea",
+	"I need to get some allergy shots",
+	"the power went out in Tennessee",
+	"um, a huge snowpocalypse hit DC",
+	'''I'm getting lunch with a "friend"''',
+	"I'm heading off to a concert",
+	'''It looks like I'll be "working" from "home" today''',
+	"I've been maliciously sunburned, and need to stay home and get jumped by my chihuahuas",
+	"I need to go get a haircut",
+]
+
 def passagg(recipient='', sender=''):
 	adj = random.choice(adjs)
 	if random.randint(0,1):