Commit 7fe43213 authored by Julien Deswaef's avatar Julien Deswaef
Browse files

Merge branch 'master' of

parents 5855187d 608679b5
def multiwordReplace(text, wordDic):
#take a text and replace words that match a key in a dictionary with
#the associated value, return the changed text
rc = re.compile('|'.join(map(re.escape, wordDic)))
def translate(match):
return wordDic[]
return rc.sub(translate, text)
class HelloBot(
def __init__(self, channel, nickname, server, port=6667):, [(server, port)], nickname, nickname) = channel
def on_welcome(self, c, e):
print "Bot connected"
def on_privmsg(self, c, e):
self.on_pubmsg(c, e)
def on_pubmsg(self, c, e):
nick = e.source.nick
if nick != 'SF-2084':
dictionary= {
'th':'all together',
'he':'it empowers',
'an':'results in',
're':'it will zip',
'er':'questions questions',
'in':'loops into',
' ':'.',
'.':'it ends',
',':'a window',
'?':'I ask myself if that is really the case',
'1':'the first',
'2':'the second',
'3':'the third',
'4':'the fourth',
'5':'the fifth',
'6':'the sixth',
'7':'the seventh',
'8':'the eighth',
'9':'the nineth'
m = e.arguments[0]
m = m.lower()
m = list(m)
for i in range(len(m)):
if not dictionary.has_key(m[i]):
new = ' '.join(m)
if ' .' in new:
new = new.replace(' .', '.')
def treatment():
count = 0
x = list(new)
for n in x:
if n ==x[0]:
x[0] = n.upper()
if n == '.' and count+2 < len(x):
x[count+2] = x[count+2].upper()
count +=1
printedtext = ''.join(x)[:400]
return printedtext+'.'
talk = 'Meanwhile in 2084: '+treatment()
if talk != None:
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='BashBot')
parser.add_argument('--host', default="localhost", help='host')
parser.add_argument('--port', type=int, default=6667, help='port')
parser.add_argument('channel', help='channel to join')
parser.add_argument('nickname', help='bot nickname')
args = parser.parse_args()
if not"#"): = "#"
bot = HelloBot(, args.nickname,, args.port)
\ No newline at end of file
Supports Markdown
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