Conflicts:
	irc.py
master
mutantmonkey 2011-12-13 14:59:30 -05:00
commit 397786ea71
3 changed files with 31 additions and 26 deletions

View File

@ -1,25 +0,0 @@
# Makefile
# Copyright 2008, Sean B. Palmer, inamidst.com
# Licensed under the Eiffel Forum License 2.
# archive - Create phenny.tar.bz2 using git archive
archive: ;
# hg archive -t tbz2 phenny-hg.tar.bz2
git archive --format=tar --prefix=phenny/ HEAD | bzip2 > phenny.tar.bz2
# ci - Check the code into git and push to github
ci: ;
# hg ci
git commit -a && git push origin master
# log - Show a log of recent updates
log: ;
# git log --date=short --format='%h %ad %s'
git graph
# sync - Push phenny to pubble:opt/phenny/
sync: ;
rsync -avz ./ pubble:opt/phenny/
help: ;
@egrep '^# [a-z]+ - ' Makefile | sed 's/# //'

6
irc.py
View File

@ -11,6 +11,7 @@ import sys, re, time, traceback
import socket, asyncore, asynchat
import ssl
class Origin(object):
source = re.compile(r'([^!]*)!?([^@]*)@?(.*)')
@ -27,6 +28,7 @@ class Origin(object):
mappings = {bot.nick: self.nick, None: None}
self.sender = mappings.get(target, target)
class Bot(asynchat.async_chat):
def __init__(self, nick, name, channels, password=None):
asynchat.async_chat.__init__(self)
@ -52,7 +54,8 @@ class Bot(asynchat.async_chat):
# print '%r %r %r' % (self, args, text)
try:
if text is not None:
self.push((b' '.join(args) + b' :' + text)[:512] + b'\r\n')
# 510 because CR and LF count too, as nyuszika7h points out
self.push((' '.join(args) + ' :' + text)[:510] + '\r\n')
else:
self.push(b' '.join(args)[:512] + b'\r\n')
except IndexError:
@ -222,6 +225,7 @@ class TestBot(Bot):
else: self.msg(origin.sender, 'pong')
f_ping.rule = r'^\.ping(?:[ \t]+(\d+))?$'
def main():
bot = TestBot('testbot007', 'testbot007', ['#wadsworth'])
bot.run('irc.freenode.net')

26
project Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# project
# Copyright 2008, Sean B. Palmer, inamidst.com
# Licensed under the Eiffel Forum License 2.
# archive - Create phenny.tar.bz2 using git archive
function archive() {
git archive --format=tar --prefix=phenny/ HEAD | bzip2 > phenny.tar.bz2
}
# commit - Check the code into git and push to github
function commit() {
git commit -a && git push origin master
}
# log - Show a log of recent updates
function history() {
git log --pretty=oneline --no-merges -10
}
# help - Show functions in project script
function help() {
egrep '^# [a-z]+ - ' $0 | sed 's/# //'
}
eval "$1"