def main(): config = ConfigParser.SafeConfigParser() config.read("chatbot.cfg") HOST = config.get('Main','host') PORT = config.getint('Main','port') NICK = config.get('Main','nick') HOSTPW = None try: HOSTPW = config.get('Main','hostpw') except: print "Host password not found, skipping..." CHANS = [] for (key, val) in config.items('Channels'): chan = None chan_pass = None val = val.strip() val = val.split(' ') if len(val) == 1: chan = val[0] if len(val) == 2: chan = val[0] chan_pass = val[1] if chan_pass: CHANS.append((chan,chan_pass)) else: CHANS.append((chan,'')) if HOSTPW: mybot = Legobot.legoBot(host=HOST,port=PORT,nick=NICK,nickpass="",chans=CHANS,hostpw=HOSTPW) else: mybot = Legobot.legoBot(host=HOST,port=PORT,nick=NICK,nickpass="",chans=CHANS) mybot.addFunc("!helloworld", helloWorld, "Ask your bot to say hello. Usage: !helloworld") mybot.addFunc("!img", bing_search, "Search Bing for a random image based on your input. Safe search is on, but you have been warned. Usage: !img [words to search]") mybot.addFunc("!roll", roll, "Roll a magical N-sided die. Usage !roll [ N>1 sides ] [number of die to roll]") mybot.addFunc("!xkcd", xkcd, "Pulls a random XKCD comic. Usage: !xkcd") mybot.addFunc("!tip", tip_user, "Tip a specific user. Usage !tip [user]") mybot.addFunc("!weather", check_weather_by_zip, "Check weather by zipcode. Usage: !weather 36429") mybot.addFunc('!printtips', print_tips, "See who has been tipped") mybot.addFunc('!wtf', wiki_search, "Wikipedia Top Finder. Grab a wikipedia article using a word or phrase as your search parameter. Usage: !wtf [parameter]") mybot.addFunc('!fraqdef', fraqdef, "Fraqture Search. Ask fraq what something is. Usage !fraqdef [parameter]") mybot.connect(isSSL=True)
def main(): config = ConfigParser.SafeConfigParser() config.read("legobot.cfg") HOST = config.get('Main','host') PORT = config.getint('Main','port') NICK = config.get('Main','nick') HOSTPW = None try: HOSTPW = config.get('Main','hostpw') except: print "Host password not found, skipping..." CHANS = [] for (key, val) in config.items('Channels'): chan = None chan_pass = None val = val.strip() val = val.split(' ') if len(val) == 1: chan = val[0] if len(val) == 2: chan = val[0] chan_pass = val[1] if chan_pass: CHANS.append((chan,chan_pass)) else: CHANS.append((chan,'')) if HOSTPW: mybot = Legobot.legoBot(host=HOST,port=PORT,nick=NICK,chans=CHANS,hostpw=HOSTPW) else: mybot = Legobot.legoBot(host=HOST,port=PORT,nick=NICK,chans=CHANS) #add functions for bot to use mybot.addFunc("!helloworld", helloWorld, "Ask your bot to say hello. Usage: !helloworld") mybot.addFunc("!xkcd", xkcd, "Pulls a random XKCD comic. Usage: !xkcd") mybot.addFunc("!tip", tip_user, "Tip a specific user. Usage !tip [user]") mybot.addFunc("!weather", check_weather_by_zip, "Check weather by zipcode. Usage: !weather 36429") mybot.addFunc('!printtips', print_tips, "See who has been tipped") mybot.connect(isSSL=True)
import urllib2 import Legobot import subprocess import time from creds import Creds from bs4 import BeautifulSoup from pydiscourse.client import DiscourseClient creds = Creds() HOST = creds.HOST PORT = creds.PORT NICK = creds.NICK PASS = creds.PASS CHANS = creds.CHANS myBot = Legobot.legoBot(host=HOST,port=PORT,nick=NICK,nickpass=PASS,chans=CHANS) client = DiscourseClient('https://0x00sec.org', api_username='******', api_key=creds.API_KEY) def NickfromMsg(msg): return msg.splitMessage[0].split("!")[0][1:] def UrlFromID(id): data = client.topic_posts(id)["post_stream"]["posts"][0] return "https://0x00sec.org/t/%s/%s" % (data["topic_slug"], data["topic_id"]) def Reconnect(): def join(msg): myBot.sendMsg("JOIN " + msg.arg1 + "\r\n")