summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-06-10 12:59:07 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-06-10 12:59:07 +0000
commita0896f6b6afb30a62702064a7e9e8e1b6148a78a (patch)
tree9c2d91da32b7ae7de0d26927b174edfaa0474bdd
parent563b504a59696a8aa6c0633d49dfde2eb6c08c4a (diff)
downloadomegle-a0896f6b6afb30a62702064a7e9e8e1b6148a78a.tar.gz
omegle-a0896f6b6afb30a62702064a7e9e8e1b6148a78a.zip
utf8-ing
git-svn-id: http://xapek.org/svn/common/omegle@1105 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rw-r--r--megahal_bot.py27
-rw-r--r--proxy.py4
2 files changed, 17 insertions, 14 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()
diff --git a/proxy.py b/proxy.py
index efb4a90..8932637 100644
--- a/proxy.py
+++ b/proxy.py
@@ -36,9 +36,9 @@ class OmegleProxyChat(OmegleChat):
def on_message(self,message):
self.idlecount = 0
- print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, message),bold=True)
+ print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, message.encode("utf-8")),bold=True)
if self.partner.is_connected:
- self.partner.send(message)
+ self.partner.send(message.decode("utf-8"))
def on_connect(self):
print self.c("%s [EVT] %s Connection confirmed" % (time.strftime("%H:%M:%S"), self.name))