diff options
Diffstat (limited to 'megahal_bot.py')
-rw-r--r-- | megahal_bot.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/megahal_bot.py b/megahal_bot.py index b9a6f6d..9865df7 100644 --- a/megahal_bot.py +++ b/megahal_bot.py @@ -1,4 +1,5 @@ import logging +import sys from threading import Event import mh_python @@ -9,17 +10,19 @@ from omegle import OmegleChat class MegahalBot(OmegleChat): - def __init__(self,disconnect_event,name,ma_host="omegle.com",color=0): + def __init__(self,disconnect_event,name,host="omegle.com",color=0): self.disconnect_event = disconnect_event self.name=name - self.color = 0 - OmegleChat.__init__(self,name="Megahal",host=ma_host) + self.color = color + OmegleChat.__init__(self,name="Megahal",host=host) self.idlecount = 0 - def c(self,str,bold=False): + def c(self,str,bold=False,color=0): + if color == 0: + color = self.color if bold: - return "\033[1m\033[%sm%s\033[0m\033[0m" %(self.color, str) + return "\033[1m\033[%sm%s\033[0m\033[0m" %(color, str) else: return "\033[%sm%s\033[0m" %(self.color, str) @@ -27,7 +30,7 @@ class MegahalBot(OmegleChat): def respond(self,message): r=mh_python.doreply(message.encode("utf-8")) print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, r),bold=True) - self.send(r) + self.send(r.decode("utf-8")) def on_idle(self): self.idlecount += 1 @@ -38,12 +41,12 @@ class MegahalBot(OmegleChat): self.logger.info("Idle count %s/8" % self.idlecount) def on_message(self,message): self.idlecount = 0 - print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), "Stranger", message),bold=True) + print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), "Stranger", message),bold=True,color=32) + time.sleep(1) self.respond(message) def on_connect(self): print self.c("%s [EVT] %s Connection confirmed" % (time.strftime("%H:%M:%S"), self.name)) - self.send(u"Hi %s!" % self.name) def on_disconnect(self): @@ -53,8 +56,6 @@ class MegahalBot(OmegleChat): if __name__ == "__main__": - colors = {"default":0, "black":30, "red":31, "green":32, "yellow":33, - "blue":34,"magenta":35, "cyan":36, "white":37, "black":38, "black":39} mh_python.initbrain() conn = pyPgSQL.PgSQL.connect("") @@ -77,8 +78,10 @@ if __name__ == "__main__": print "press ctrl-c to abort" event = Event() - #bot=MegahalBot(event,"A",ma_host="localhost:8082",color=colors['red']) - bot=MegahalBot(event,"A",color=colors['red']) + if len(sys.argv) == 2: + bot=MegahalBot(event,"A",host=sys.argv[1],color=31) + else: + bot=MegahalBot(event,"A",host="omegle.com",color=31)#red bot.start() |