class SEChatBot: def __init__(self, site="SE",trigger="!!"): self.wrap=SEChatWrapper(site) self.watchers=[] def login(self, username, password): self.wrap.login(username,password) def joinRoom(roomno): "Join some room" def watchCommand(commandname,handler): "Watch for a command, handler should take (args,roomnumber) as arguments and return a reply" def postMessage(roomno,message): "Expose inner postMessage here" def _watcher(): "Use array of watch functions to watch room"
def __init__(self, site="SE",trigger="!!"): self.wrap=SEChatWrapper(site) self.watchers=[]
parser=HTMLParser.HTMLParser() if("ChatExchangeU" in os.environ): username=os.environ["ChatExchangeU"] else: print "Username: "******"ChatExchangeP" in os.environ): password=os.environ["ChatExchangeP"] else: password=getpass.getpass("Password: "******"SE") wrap.login(username,password) wrapm=SEChatWrapper("MSO") wrapm.login(username,password) s="[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] SmokeDetector started" wrap.sendMessage("11540",s) def checkifspam(data): global lasthost,lastid d=json.loads(json.loads(data)["data"]) s= d["titleEncodedFancy"] print time.strftime("%Y-%m-%d %H:%M:%S"),parser.unescape(s).encode("ascii",errors="replace") site = d["siteBaseHostAddress"] site=site.encode("ascii",errors="replace") sys.stdout.flush() test=FindSpam.testpost(s,site)
#requires https://pypi.python.org/pypi/websocket-client/ import json, os, sys, getpass from ChatExchange.SEChatWrapper import * if ("ChatExchangeU" in os.environ): username = os.environ["ChatExchangeU"] else: print "Username: "******"ChatExchangeP" in os.environ): password = os.environ["ChatExchangeP"] else: password = getpass.getpass("Password: "******"MSO") wrap = SEChatWrapper("SE") wrap.login(username, password) s = "[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] %s" % sys.argv[ 1] print s wrap.sendMessage("11540", s) #wrap.sendMessage("89",s) import time time.sleep(5)
import os import getpass from ChatExchange.SEChatWrapper import * from BeautifulSoup import * if "ChatExchangeU" in os.environ: username = os.environ["ChatExchangeU"] else: print "Username: "******"ChatExchangeP" in os.environ: password = os.environ["ChatExchangeP"] else: password = getpass.getpass("Password: "******"SE") wrap.login(username, password) url = "https://github.com/Manishearth/ChatExchange-Scripts/blob/master/lazers.py" prefix = "[ [LAZERS v2](%s) ]" % url def handlepost(data): a = json.loads(json.loads(data)['data']) tags = a['tags'] link = BeautifulSoup(a['body']).find('a', {'class': 'question-hyperlink'}) msg = "{prefix} [{title}]({url}) %s".format( prefix=prefix, title=" ".join(link.contents), url="http://gaming.stackexchange.com" + link['href'], tags=" ".join("[tag:%s]" % t for t in tags)
#requires https://pypi.python.org/pypi/websocket-client/ import json,os,sys,getpass from ChatExchange.SEChatWrapper import * if("ChatExchangeU" in os.environ): username=os.environ["ChatExchangeU"] else: print "Username: "******"ChatExchangeP" in os.environ): password=os.environ["ChatExchangeP"] else: password=getpass.getpass("Password: "******"MSO") wrap=SEChatWrapper("SE") wrap.login(username,password) s="[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] %s" % sys.argv[1] print s wrap.sendMessage("11540",s) #wrap.sendMessage("89",s) import time time.sleep(5)
#requires https://pypi.python.org/pypi/websocket-client/ import json,os,sys,getpass from ChatExchange.SEChatWrapper import * #wrap=SEChatWrapper("MSO") wrap=SEChatWrapper("SE") wrap.login(sys.argv[2],sys.argv[3]) s="\[[Blaze](https://github.com/Charcoal-SE/Blaze)] %s" % sys.argv[1] print s wrap.sendMessage("11540",s) #wrap.sendMessage("89",s) import time time.sleep(5)
#requires https://pypi.python.org/pypi/websocket-client/ import json, os, sys, getpass from ChatExchange.SEChatWrapper import * #wrap=SEChatWrapper("MSO") wrap = SEChatWrapper("SE") wrap.login(sys.argv[2], sys.argv[3]) s = "\[[Blaze](https://github.com/Charcoal-SE/Blaze)] %s" % sys.argv[1] print s wrap.sendMessage("11540", s) #wrap.sendMessage("89",s) import time time.sleep(5)