Created
July 2, 2015 23:49
-
-
Save zodman/96b43168241d9712886a to your computer and use it in GitHub Desktop.
chatango snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import ch | |
import sys | |
msg = "" | |
import cgi | |
class TestBot(ch.RoomManager): | |
def onConnect(self, room): | |
global msg | |
#print "<span style='text-style:bold;'>send:</span> %s" % msg | |
room.ping() | |
nick, txt = msg.split(":") | |
msg_ = u":".join([nick, txt.decode("utf-8").encode('ascii', 'xmlcharrefreplace')]) | |
print msg_ | |
room.message(msg_, html = True) | |
room.ping() | |
if __name__ == "__main__": | |
msg = " ".join(sys.argv[1:]) | |
TestBot.easy_start(rooms=["hoshizorasubs"], name="desdeirc", password="*****") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zodman@mail:~/apps/fansubbers/bot_plugins/ch$ cat chatangoreader.py | |
#!/usr/bin/python | |
import ch | |
import redis | |
class TestBot(ch.RoomManager): | |
key ="chatango" | |
def onConnect(self, room): | |
self.redis = redis.StrictRedis(host="localhost", port=6379) | |
self.redis.rpush(self.key, "Connected to "+room.name) | |
print "connect" | |
def onEventCalled(self, room, evt, *args, **kw): | |
print room, evt, args, kw | |
def onReconnect(self, room): | |
self.redis.rpush(self.key,"Reconnected to "+room.name) | |
def onDisconnect(self, room): | |
self.redis.rpush(self.key, "Disconnected from "+room.name) | |
import sys | |
sys.exit(1) | |
def onMessage(self, room, user, message): | |
# Use with PsyfrBot framework? :3 | |
msg = user.name + ': ' + message.body | |
print msg | |
self.redis.rpush(self.key, msg) | |
def onFloodBan(self, room): | |
msg = ("You are flood banned in "+room.name) | |
self.redis.rpush(self.key, msg) | |
def onPMMessage(self, pm, user, body): | |
msg = 'PM: ' + user.name + ': ' + body | |
self.redis.rpush(self.key, msg) | |
if __name__ == "__main__": | |
TestBot.easy_start(rooms=["hoshizorasubs"], name="ircbot", password="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing your work. Unfortunately it seems to be a little over my head currently.