Commit b25c5dde authored by Jonathan Harker's avatar Jonathan Harker
Browse files

Now logging to stdout.

parent 0f6df932
......@@ -7,13 +7,16 @@
Useful bot for folks stuck behind censor walls at work
Logs a channel and collects URLs for later.
import sys, string, random, time
from ircbot import SingleServerIRCBot
from irclib import nm_to_n, nm_to_h, irc_lower
import botcommon
import time
import os
from datetime import datetime
from mechanize import Browser
# Exclamations - wrong input
......@@ -31,6 +34,8 @@ ponderings = [
"Hi, can I have a medium lamb roast, with just potatoes.",
"Can I slurp on your Big Cock?",
"Your Mum likes it two in the pink one in the stink.",
"Quentin Tarantino is so awesome I want to have his babies.",
"No it's a week night 8pm is past my bedtime.",
class LolBot(SingleServerIRCBot):
......@@ -40,7 +45,6 @@ class LolBot(SingleServerIRCBot): = channel
self.nickname = nickname
self.urls = {}
self.logfile = open('/tmp/lolbot.log', 'a')
self.helptext = "Adds URLs to a list. Commands: list - prints a bunch of URLs; clear - clears the list; lol - say something funny; <url> - adds the URL to the list; help - this message."
......@@ -54,11 +58,18 @@ class LolBot(SingleServerIRCBot):
title = br.title()
except Exception as ex:
print ex
title = ''
self.urls[url] = title
return title
def now(self):
return"%Y-%m-%d %H:%M:%S")
def log_event(self, event):
nick = nm_to_n(event.source())
text = event.arguments()[0]
print "(%s) %s: %s" % (, nick, text)
def on_nicknameinuse(self, connection, event):
self.nickname = connection.get_nickname() + "_"
......@@ -75,7 +86,7 @@ class LolBot(SingleServerIRCBot):
"Deal with a public message in a channel."
# log it
self.logfile.write("%s\n" % event.arguments()[0])
from_nick = nm_to_n(event.source())
args = string.split(event.arguments()[0], ":", 1)
......@@ -92,6 +103,7 @@ class LolBot(SingleServerIRCBot):
def say_public(self, text):
"Print TEXT into public channel, for all to see."
print "(%s) %s: %s" % (, self.nickname, text)
def say_private(self, nick, text):
"Send private message of TEXT to NICK."
......@@ -105,7 +117,7 @@ class LolBot(SingleServerIRCBot):
def ponder(self):
"Return a random string indicating what Pinky's pondering."
"Return a random pondering."
return random.choice(ponderings)
def exclaim(self):
......@@ -119,15 +131,10 @@ class LolBot(SingleServerIRCBot):
if event.eventtype() == "pubmsg":
# self.reply() sees 'from_private = None' and sends to public channel.
target = None
# assume that from_private comes from a 'privmsg' event.
target = from_private.strip()
# Be forgiving about capitalization and whitespace.
#cmd = cmd.replace(" ", "").lower()
if cmd == 'help':
self.reply(self.helptext, target)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment