Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from ConfigParser import RawConfigParser as ConfParser
- from BeautifulSoup import BeautifulSoup
- from optparse import OptionParser
- from collections import deque
- from time import sleep, time, gmtime, strftime
- import ConfigParser
- import os
- import sys
- import socket
- import codecs
- from irc import *
- from select import select
- import urllib
- import imp
- import modules.fml
- import modules.meme
- import modules.bitly
- import threading
- my = IRCbot()
- server = "localhost"
- port = 1026
- nickpass = "test"
- operlogin = "t2 t5"
- channels = "#chat"
- internets = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
- internets.connect((server, port))
- version = "1.0.0"
- def internets_bot(sock):
- internets.send('NICK Internets\r\n')
- internets.send('USER python Internets Internets :[Internets %s]\r\n' % version)
- while 1:
- data = readline(sock)
- raw = parse(data)
- #print("[Internets] %s" % raw)
- if raw[0].lower() == "ping":
- internets.send("PONG {reply}\r\n".format(reply = raw[1]))
- if raw[0].lower().startswith("nickserv!"):
- if raw[1] == "NOTICE" and "This nickname is registered" in raw[3]:
- internets.send('PRIVMSG NickServ :identify %s \r\n' % nickpass)
- internets.send('OPER %s \r\n' % operlogin)
- internets.send('JOIN %s \r\n' % channels)
- if raw[1] == "PRIVMSG":
- my.sender = raw[0]
- my.nick = raw[0].split("!")[0]
- my.auth = data.split('@')[0][1:]
- if len(raw) > 3:
- if raw[3] == ".uptime":
- end = time()
- uptime = end - start
- internets.send('PRIVMSG %s :Internets is running for %s \r\n' % (raw[2], duration_human(uptime)))
- if raw[3].startswith(".reload "):
- try:
- if config.get('staff', my.auth) == 'admin':
- if raw[3].split(" ", 1)[1] == "fml":
- imp.reload(modules.fml)
- internets.send('PRIVMSG %s :Reloaded FML module.\r\n' % raw[2])
- except ConfigParser.NoOptionError:
- continue
- if raw[3] == ".info":
- internets.send('PRIVMSG %s :Internets %s by Aha2Y.\r\n' % (raw[2], version))
- imp.reload(modules.meme)
- if raw[3] == ".fml":
- q = modules.fml.get()
- internets.send('PRIVMSG %s :[fml/#%s] %s\r\n' % (raw[2], q.number, q.text))
- internets.send('PRIVMSG %s :%s - %s\r\n' % (raw[2], q.agree, q.disagree))
- if raw[3] == ".meme":
- q = modules.meme.get()
- internets.send('PRIVMSG %s :[Meme] %s\r\n' % (raw[2], q.meme))
- imp.reload(modules.meme)
- if raw[3].startswith(".slogan"):
- try:
- slogan_topic = raw[3].split(" ", 1)[1]
- slogan_url = urllib.urlopen("http://parsers.faux-bot.com/slogan/%s" % slogan_topic)
- slogansoup = BeautifulSoup(slogan_url)
- x = str(slogansoup)
- x = x.split()
- slogan = " ".join(x[1:]).strip("End Response:")
- internets.send('PRIVMSG %s :[SloganMaker] "%s"\r\n' % (raw[2], slogan))
- except:
- internets.send('NOTICE %s :Syntax: .slogan <url>\r\n' % my.nick)
- if raw[3].startswith(".shorten"):
- try:
- shorten = raw[3].split(" ", 1)[1]
- api = modules.bitly.Api(login='aha2y', apikey='R_68fd8f8405600aab706feecbc07ea066')
- short=api.shorten(shorten,{'history':1})
- internets.send('PRIVMSG %s :[Bitly] %s\r\n' % (raw[2], short))
- except:
- internets.send('NOTICE %s :Syntax: .shorten <url>\r\n' % my.nick)
- internets_thread = threading.Thread(target = internets_bot, args = (internets, )) # Thread object
- internets_thread.start()
- internets_thread.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement