1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| #
# Released Under WTFPL
# http://sam.zoy.org/wtfpl/
#
from jabberbot import JabberBot
import gtrans
import random
# Gmail uses Jabber, but their TOS doesn't allow automated scripts. So be warned
username = 'yourJabberID@example.com'
password = 'password'
# Just some famous dialogues from Vadivelu comedy tracks. Might not make sense if you
# don't know who or what vadivelu is.
error_dialogues = [
"Nee yaaru kitta paysikittu irrukaynu theriyuma? Sekar ngara oru TERROR kitta",
"Saykar settutaan",
"Tirisa illana Divya",
"Huh.. yennaku body strong basement weeeku",
"Naanum rowdy.. naanum rowdy.. naanum rowdy",
"Shabba... ippovae kannu kattudae",
"Heloooo.. Ennoda biruther maark irukaara",
"Don't worry.. Be gaaapy",
"But andha dealing enaku pudichi irundhuchi",
"lighta...",
"Vaynda... Vallikidu.... Azuthuduvane.. Azhuthuduvane",
"Sing in the raine... I am swoying in the raine..",
"Helloo.. Prabha wine shop ownerungala? Kadaiya.. yeppo saar tharapeenga?",
" romba nallavanu enna pathu sollitanmaaaaa..."
]
class NaiSaykarBot(JabberBot):
def bot_trans(self, msg, args):
"""Translate the phrase/sentence from the source language to the required language
ex: trans en pl Apples grow in trees
would translate the above phrase from english to polish
"""
split = args.split()
if len(split) == 0:
return
src_language = split[0].strip()
required_language = split[1].strip()
phrase = ' '.join(split[2:])
try:
translated = gtrans.translate(src_language, required_language, phrase)
return translated
except gtrans.InvalidLanguage, e:
print "Invalid args : %s" %(args)
# Return a random error message
return random.choic e(error_dialogues)
# Overridden from JabberBot
def unknown_command( self, mess, cmd, args):
print "Unknown Command %s" %(args)
return random.choice(error_dialogues)
if __name__ == '__main__':
bot = NaiSaykarBot(username, password)
bot.serve_forever()
|