Advertisement
BeamNG_IRC

BeamBot

Jan 10th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 54.51 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. #For 3phasegaming.net
  3. #BeamNG Made by Dan Jones, MrBill, Brocky, BadSol and tdev
  4. import socket
  5. import sys
  6. import re
  7. import urllib
  8. import urllib2
  9. class IRCClient:
  10.     socket = None
  11.     connected = False
  12.     nickname = 'BeamBot'
  13.     channels = ['#BeamNG']
  14.     def __init__(self):
  15.         self.socket = socket.socket()
  16.         self.socket.connect(('3phasegaming.net', 6667))
  17.         self.send("NICK %s" % self.nickname)
  18.         self.send("USER %(nick)s %(nick)s %(nick)s :%(nick)s" % {'nick':self.nickname})
  19.         links = 0
  20.         self.send("join #beamng")
  21.         self.send("join #dan'shangout")
  22.         self.send("join #tests")
  23.         fun = 1
  24.         def get_data(seed): # function for getting json data on the seed provided
  25.             import urllib2
  26.             response = urllib2.urlopen('http://api.randomuser.me/?seed=' + seed) # fetches the websites data
  27.             html = response.read() # saves the data into a string
  28.             parse_data(html) # sends data to be parse_data
  29.         def parse_data(data): # function that parses the json file recieved
  30.             gender = data.split('gender":"')[1].split('"')[0]
  31.             title = data.split('title":"')[1].split('"')[0]
  32.             fname = data.split('first":"')[1].split('"')[0]
  33.             lname = data.split('last":"')[1].split('"')[0]
  34.             street = data.split('street":"')[1].split('"')[0]
  35.             city = data.split('city":"')[1].split('"')[0]
  36.             state = data.split('state":"')[1].split('"')[0]
  37.             email = data.split('email":"')[1].split('"')[0]
  38.             username = data.split('username":"')[1].split('"')[0]
  39.             password = data.split('password":"')[1].split('"')[0]
  40.             phone = data.split('phone":"')[1].split('"')[0]
  41.             cell = data.split('cell":"')[1].split('"')[0]
  42.             picture = data.split('picture":"')[1].split('"')[0]
  43.             tosay = '\x02Name:\x02 ' + title.title() + ' ' + fname.title() + ' ' + lname.title() + ' \x02Picture:\x02 ' + picture
  44.             tosay = str((tosay))
  45.             self.say((tosay), target)
  46.         while True:
  47.             buf = self.socket.recv(4096)
  48.             lines = buf.split("\n")
  49.             for data in lines:
  50.                 data = str(data).strip()
  51.                 if data == '':
  52.                     continue
  53.                 print "I<", data
  54.                 # Ping/Pong script
  55.                 if data.find('PING') != -1:
  56.                     n = data.split(':')[1]
  57.                     self.send('PONG :' + n)
  58.                     if self.connected == False:
  59.                         self.perform()
  60.                         self.connected = True
  61.                 args = data.split(None, 3)
  62.                 if len(args) != 4:
  63.                     continue
  64.                 ctx = {}
  65.                 ctx['sender'] = args[0][1:]
  66.                 ctx['type'] = args[1]
  67.                 ctx['target'] = args[2]
  68.                 ctx['msg'] = args[3][1:]
  69.                 names = ctx['sender'].split("!")[0]
  70.                 from datetime import datetime
  71.                 t = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  72.                 # Target
  73.                 target = ctx['target']
  74.                 if ctx['target'] == self.nickname:
  75.                     target = ctx['sender'].split("!")[0]
  76.                     #variable for display of name is below
  77.                 #name = (ctx['msg'].split(":") [1]) name =
  78.                 #(ctx['sender'].split("!") [0])
  79.                 user = (target)
  80.                 new = (ctx['msg'] + ': ')
  81.                 newsay = (ctx['msg'])
  82.                 new2 = (ctx['sender'])
  83.                 name = (new2.split("!")[0])
  84.                 logname = (new2)
  85.                 say = (new)
  86.                 log = "yes"
  87.         # For URLs, split into only 2 parts instead of individual words
  88.                 nick = ctx['sender'].split("!")[0]
  89.                 #clear = (ctx['msg'])
  90.                 password = '911SECRET'
  91.                 password2 = 'FOROPSONLY'
  92.                 password3 = ''
  93.                 # LOG WRITING
  94.                 #self.say("\x02 https://www.google.com/search?q=" + (url.lower())[5:] + "&" + "btnI=I'm+Feeling+Lucky" + '\x02', target)
  95.                 if log == "yes":
  96.                     if data.find('#beamng') != -1:
  97.                         #logged = ("\n |*****Chat Detected: " + '\x02' + (ctx['msg']) + '\x02' + " By IRC user: " + '\x02' + (ctx['sender'].split("!") [0] + "*****|\n"))
  98.                         #log = ((ctx['msg']) + '\x02' + " By IRC user: " + '\x02' + (ctx['sender'].split("!") [0]))
  99.                         log = (t) + ' ' + (logname) + ": > " + (ctx['msg']) + "\n"
  100.                         file = open("BeamNG.txt", "ab+")
  101.                         file.write('\n' + (log))
  102.                         file.close()
  103.                     if data.find('#tests') != -1:
  104.                         #logged = ("\n |*****Chat Detected: " + '\x02' + (ctx['msg']) + '\x02' + " By IRC user: " + '\x02' + (ctx['sender'].split("!") [0] + "*****|\n"))
  105.                         #log = ((ctx['msg']) + '\x02' + " By IRC user: " + '\x02' + (ctx['sender'].split("!") [0]))
  106.                         log = (t) + ' ' + (logname) + ": > " + (ctx['msg']) + "\n"
  107.                         file = open("tests.txt", "ab+")
  108.                         file.write('\n' + (log))
  109.                         file.close()
  110.                 # LOG END
  111.                         print "\n |*****Chat Detected: " + '\x02' + (ctx['msg']) + '\x02' + " From: " + '\x02' + (ctx['sender'].split("!") [0] + "*****|\n")
  112.                         say2 = (say.split(" ")[0])
  113.                 # Commands start here
  114.                 # Testing PRIVMSG filtering, for special occasions, ops etc
  115.                   #respond = ctx['msg']
  116.                 if data.find('BeamBot') != -1:
  117.                     ctx['msg'] = ctx['msg'].replace(((new)[5:]), 'BeamNG')
  118.                     target = '#BeamNG'
  119.                 if ctx['msg'].upper().split(" ")[0] == (password):
  120.                         self.say((newsay)[10:], target)
  121.                 #if ctx['msg'].upper().split(" ")[0] == (password2):
  122.                     #self.send((newsay)[10:])
  123.                 if data.find('BeamBot') != -1:
  124.                     ctx['msg'] = ctx['msg'].replace(((new)[5:]), 'BeamNG')
  125.                     target = '#BeamNG'
  126.                 if ctx['msg'].upper().split(" ")[0] == (password2):
  127.                         self.send((newsay)[10:])
  128.                 # Self help section, baiscally i'm kind of tired of the same old questions, so I let the bot do some work
  129.                 raw = (data).upper()
  130.                 if raw.find('X3DAUDIO1_7.DLL') != -1 and raw.find('MISSING') != -1 :
  131.                     self.say('\x02' + (name) + ': ' '\x02'  + 'DirectX error: DirectX errors can be resolved by following this link - http://www.microsoft.com/en-us/download/details.aspx?id=35', target)
  132.                # Detect when a user connects, and if they have a tell to read
  133.                 if data.find('!') != -1 and data.find('@') != -1 and data.find('#') != -1 and data.find('#BeamNG') != -1 :
  134.                     already = "tells/annoy/" + (nick) + ".txt"
  135.                     from os import path, access, R_OK
  136.                     if path.isfile(already) and access((already), R_OK):
  137.                         print "user already recieved warning"
  138.                     else:
  139.                         from os import path, access, R_OK
  140.                         exist = "tells/" + (nick) + ".txt"
  141.                         if path.isfile(exist) and access((exist), R_OK):
  142.                             self.send('PRIVMSG ' + '#BeamNG ' + '\x02' + (nick) + '\x02 You have tells pending, type !showtells to view them.')
  143.                             already1 = "tells/annoy/" + (nick) + ".txt"
  144.                             already2 = open((already1), "ab+")
  145.                             already2.write('dont annoy him')
  146.                             already2.close()
  147.         commandprefix = ("?", "!")
  148.                 if ctx['msg'].startswith(commandprefix):
  149.                   message = ctx['msg'].split(" ", 1)
  150.                   urltuple = ('?YOUTUBE', '?WIKIPEDIA', '?GOOGLE4U', '?GOOGLE4U2', '?GOOGLE', '?URBAN', '?USER')
  151.                   command = message[0].upper()
  152.                   if command in urltuple:
  153.                     if command == '?YOUTUBE':
  154.                       self.say("\x02" + "http://www.youtube.com/results?search_query=" + self.delimit(message[1], "+") + "&sm=3" + '\x02', target)
  155.                     if command == '?WIKIPEDIA':
  156.                       self.say("\x02" + "http://en.wikipedia.org/wiki/" + self.delimit(message[1], "_") + '\x02', target)
  157.                     if command == '?GOOGLE4U':
  158.                       self.say("\x02" + "http://lmgtfy.com/?q=" + self.delimit(message[1], "+") + '\x02', target)
  159.                     if command == '?GOOGLE4U2':
  160.                       self.say("\x02" + "http://lmgtfy.com/?q=" + self.delimit(message[1], "+") + '&l=1' '\x02', target)
  161.                     if command == '?GOOGLE':
  162.                       self.say("\x02" + "http://www.google.com/search?q=" + self.delimit(message[1], "+") + '\x02', target)
  163.                     if command == '?URBAN':
  164.                       self.say("\x02" + "http://www.urbandictionary.com/define.php?term=" + self.delimit(message[1], "+") + '\x02', target)
  165.                     if command == '?USER':
  166.                       self.say("http://www.beamng.com/member.php?username=" + self.delimit(message[1], "%20"), target)
  167.                       #self.say("\x02 http://www.google.com/webhp#q=" +(url.lower())[7:] + "&btnI", target)
  168.                   else:
  169.                     if len(message) > 1:
  170.                       body = message[1].split()
  171.                     else:
  172.                       body = [""]
  173.             if command == '?DEBUG':
  174. #              self.say(len(ctx['msg']), target)
  175. #              self.say(len(url5), target)
  176. #              self.say(len(message), target)
  177.                       print locals()
  178.                     if command == '?LASTORDER' or command == '?LOSTCODE' or command == '?LATESTORDER':
  179.                       self.say(self.format(body[0]) + 'To retrieve a lost download please visit http://www.beamng.com/service/latestorder - Check your e-mail for information on your Order ID (if necessary)', target)
  180.                     #if command == '?SAY':
  181.                       #   self.say((newsay)[5:], target)
  182.                     if command == '?SERVERTIME':
  183.                       self.say((t), target)
  184.                     if command == '?PLAYING':
  185.                       self.say(self.format(body[0]) + 'For information about playing, see http://wiki.beamng.com/Playing', target)
  186.                     if command == '?MAC':
  187.                       self.say(self.format(body[0]) + 'Mac users: You cannot play BeamNG natively on OS X. You can however do it through Wine or Parallels.', target)
  188.                     if command == '?D3D' or command == '?DIRECTX':
  189.                       self.say(self.format(body[0]) + 'DirectX error: DirectX errors can be resolved by following this link - http://www.microsoft.com/en-us/download/details.aspx?id=35', target)
  190.                     if command == '?WIKI':
  191.                       self.say(self.format(body[0]) + 'The BeamNG Wiki answers a lot of questions you may have: - http://wiki.beamng.com/', target)
  192.                     if command == '?FAQ':
  193.                       self.say(self.format(body[0]) + 'The FAQ (Frequently Asked Questions) is a useful resource for resolving issues! - http://wiki.beamng.com/BeamNG_FAQ', target)
  194.                     if command == '?SYMBOLS':
  195.                       self.say(self.format(body[0]) + '[@] - Intended for official BeamNG developers; [%] - Intended for channel operators, A.K.A moderators; [+] - Intended for respected members of the community', target)
  196.                     if command == '?DEMO':
  197.                       self.say(self.format(body[0]) + 'BeamNG has a free-to-play tech demo, perfect for evaluating the quality of gameplay on your system! - http://www.beamng.com/techdemo', target)
  198.                     if command == '?MODS':
  199.                       self.say(self.format(body[0]) + 'There are a wide variety of game modifications and new amazing levels made by the community available to download, these are however restricted to members of the alpha stage of BeamNG.', target)
  200.                     if command == '?BUGS':
  201.                       self.say(self.format(body[0]) + 'A list of known bugs is available at: http://www.beamng.com/threads/1479-List-of-known-bugs-(please-read-before-posting!)', target)
  202.                     if command == '?CONTROLLER':
  203.                       self.say(self.format(body[0]) + 'Setting up a controler with BeamNG can be difficult. A full list of instructions are available here: http://wiki.beamng.com/Playing#Configuring_your_own_controller', target)
  204.                     if command == '?CHANGELOG':
  205.                       self.say(self.format(body[0]) + 'A changelog is available here: http://wiki.beamng.com/Changelog', target)
  206.                     if command == '?ALPHA':
  207.                       self.say(self.format(body[0]) + 'The Alpha version of BeamNG is available for purchase by following this link: http://beamng.com/store', target)
  208.                     if command == '?VEHICLES':
  209.                       self.say(self.format(body[0]) + 'Downloadable vehicles are available here (Alpha users only): http://www.beamng.com/forums/26-Vehicles', target)
  210.                     if command == '?MAPS':
  211.                       self.say(self.format(body[0]) + 'Downloadable maps are avaiable here (Alpha users only): http://www.beamng.com/forums/27-Terrains', target)
  212.                     if command == '?FOLDER':
  213.                       self.say(self.format(body[0]) + 'To access the BeamNG folder, press your Windows key + R key and type this: %userprofile%\\appdata\local\BeamNG\BeamNG-DRIVE-0.3', target)
  214.                     if command == '?CPU':
  215.                       self.say(self.format(body[0]) + 'To check what CPU you have, visit this site: http://www.wikihow.com/Tell-What-Kind-of-Processor-You-Have', target)
  216.                     if command == '?GPU':
  217.                       self.say(self.format(body[0]) + 'To check what GPU you have, visit this site: http://www.wikihow.com/Find-Out--What-Graphics-Card-You-Have', target)
  218.                     if command == '?CONTACT':
  219.                       self.say(self.format(body[0]) + 'Contacting the BeamNG team will allow certain issues to be fixed directly! - http://www.beamng.com/contactus/', target)
  220.                     if command == '!SHOWTROLLS':
  221.                       with open ("trolls.txt", "r") as myfile:
  222.                           troll=myfile.read().replace('\n', ' ')
  223.                           self.say('Trolls: ' + (troll), target)
  224.                     if command == '!LINECOUNT':
  225.                         count = 0
  226.                         textfile = open('BeamNG.txt', 'r')
  227.                         file = textfile
  228.                         for line in file:
  229.                             count += 1
  230.                         file.close()
  231.                         count = str((count))
  232.                         self.say('The log is ' + count + ' lines big', target)
  233.                     if command == '?ANNOUNCEMENT':
  234.                         html = self.webrequest('http://www.beamng.com')
  235.                         announce = self.htmlfind(html, '<b>', '</b>')
  236.                         self.say((announce), target)
  237.                     if command == '!LINKS':
  238.                         if data.find('daniel_j') != -1:
  239.                             if links == 0:
  240.                                 self.say('Links now enabled.', target)
  241.                                 links = 1
  242.                             else :
  243.                                 self.say('Links now disabled.', target)
  244.                                 links = 0
  245.                         else:
  246.                             print "nope"
  247.                     if command == '!FUN':
  248.                         if data.find('daniel_j') != -1:
  249.                             if fun == 0:
  250.                                 self.say('Fun enabled.', target)
  251.                                 fun = 1
  252.                             else :
  253.                                 self.say('Fun now disabled.', target)
  254.                                 fun = 0
  255.                         else:
  256.                             print "nope"
  257.                     if command == '?WHUT':
  258.                         if fun == 1:
  259.                             import random
  260.                             s_nouns = ["A dude", "My mom", "The king", "Some guy", "A cat with rabies", "A sloth", "Your homie", "This cool guy my gardener met yesterday", "Superman"]
  261.                             p_nouns = ["These dudes", "Both of my moms", "All the kings of the world", "Some guys", "All of a cattery's cats", "The multitude of sloths living under your bed", "Your homies", "Like, these, like, all these people", "Supermen"]
  262.                             s_verbs = ["eats", "kicks", "gives", "treats", "meets with", "creates", "hacks", "configures", "spies on", "retards", "meows on", "flees from", "tries to automate", "explodes"]
  263.                             p_verbs = ["eat", "kick", "give", "treat", "meet with", "create", "hack", "configure", "spy on", "retard", "meow on", "flee from", "try to automate", "explode"]
  264.                             infinitives = ["to make a pie.", "for no apparent reason.", "because the sky is green.", "for a disease.", "to be able to make toast explode.", "to know more about archeology.", "because daniel_j is awesome", "to hack the database"]
  265.                             random = random.choice(s_nouns), random.choice(s_verbs), random.choice(s_nouns).lower() or random.choice(p_nouns).lower(), random.choice(infinitives)
  266.                             random = str(random).replace('(', "")
  267.                             random = str(random).replace(')', "")
  268.                             random = str(random).replace("'", "")
  269.                             random = str(random).replace(",", "")
  270.                             self.say((random), target)
  271.                     if len(message) <= 1:
  272.                       break
  273. ####################################################################################################################################################################################################################################
  274. ###########         Commands below this line will NOT work without arguments.  If you need a command that works without an argument, add it ABOVE this line. #######################################################################
  275. ####################################################################################################################################################################################################################################
  276.                     if command == '!ADD':
  277.                       file = open("trolls.txt", "ab+")
  278.                       file.write(' ' + (body[0]))
  279.                       file.close()
  280.                       self.say('Added \x02' + (body[0]) + '\x02 to troll list.', target)
  281.                     if command == '!REMOVE':
  282.                       self.say('Removed \x02' + (body[0]) + '\x02 from troll list.', target)
  283.                       import fileinput
  284.                       files = "trolls.txt"
  285.                       for line in fileinput.input(files, inplace = 1):
  286.                           print line.replace((body[0]), ""),
  287.                     # Tell system tests
  288.                     if command == '!TELL':
  289.                       from os import path, access, R_OK
  290.                       exist = "tells/" + (body[0]) + ".txt"
  291.                       if path.isfile(exist) and access((exist), R_OK):
  292.                           self.say('\x02' + (body[0]) + '\x02 already has a message to read!', target)
  293.                       else:
  294.                           from datetime import datetime
  295.                           t = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  296.                           length = len(body[0])
  297.                           flength = 6 + (length)
  298.                           tell = open((exist), "ab+")
  299.                           tell.write((ctx['msg'][(flength):]) + ' - From: \x02' + (name) + '\x02 - ' + (t))
  300.                           tell.close()
  301.                           self.say("I'll tell " + (body[0]) + ' that.', target)
  302.                     if command == '!COUNT':
  303.                         count = 0
  304.                         textfile = open('BeamNG.txt', 'r')
  305.                         file = textfile
  306.                         for line in file:
  307.                             if (body[0]) in line:
  308.                                 count += 1
  309.                         file.close()
  310.                         count = str((count))
  311.                         self.say((body[0]) + ' said ' + (count) + ' times', target)
  312.                     if (command == '?REG' or command == '?ACTIVE' or command == '?ACTIVATED'):
  313.                         values = { 'username' : message[1] }
  314.                         html = self.encodeurl("http://www.beamng.com/member.php", values)
  315.                         reg = self.htmlfind(html, '<span class="rank">', '</span>')
  316.                         rank = self.htmlfind(html, '<span class="usertitle">', '</span>')
  317.                         if reg.find('supporter') != -1 or rank.find('Developer') != -1 or rank.find('Vehicle Artist') != -1:
  318.                             self.say('\x0309,01\x02' + (message[1]) + "'s\x02\x0f account \x0309,01\x02IS\x02\x0f activated.", target)
  319.                         else:
  320.                             self.say('\x0304,01\x02' + (message[1]) + "'s\x02\x0f account \x0304,01\x02NOT\x02\x0f activated.", target)
  321. #                    if command == '!D':
  322. #                        word = self.delimit(message[1], "+")
  323. #                        link = "http://www.thefreedictionary.com/" + (word)
  324. #                        response = urllib2.urlopen(link)
  325. #                        html = response.read()
  326. #                        begin = html.find('<div class="ds-single">')
  327. #                        end = html.find('</div>',begin)
  328. #                        defi = html[begin+len('<div class="ds-single">'):end].strip()
  329. #                        if len(defi) > 100 or defi.find('<') != -1:
  330. #                            self.say((word) + ' not found.', target)
  331. #                        else:
  332. #                            self.say((defi), target)
  333.                     if command == '!D':
  334.                         if fun == 1:
  335.                             try:
  336.                                 html = self.webrequest("http://www.oxforddictionaries.com/definition/english/" + urllib.quote(message[1]))
  337.                                 defi = self.htmlfind(html, 'definition">', '</span>')
  338. #                                defi.replace('[','')
  339. #                                defi.replace(']','')
  340. #                                defi.replace('&#39;',"'")
  341. #                                defi.replace('&quot;','"')
  342. #                                defi = defi.split('<')[0]
  343. #                                defi = defi[:-1]
  344.                                 if len(defi) > 199:
  345.                                     defi = defi[:200]
  346.                                     defi = (defi) + ' (.....)'
  347.                                 print((defi))
  348.                                 if len(defi) > 400 or defi.find('BLIC') != -1:
  349.                                     self.say('\x02"' + (message[1]) + '"\x02' + ' not found in the dictionary.', target)
  350.                                 else:
  351.                                     self.say('\x02' + (message[1]) + ':\x02 ' +(defi), target)
  352.                             except urllib2.HTTPError, error:
  353.                                 print error
  354.                             except:
  355.                                 print "Error:", sys.exc_info()
  356.                                 self.say('\x02"' + (message[1]) + '"\x02' + ' not found in the dictionary.', target)
  357.                     if command == '?WHOIS':
  358.                         if fun == 1:
  359.                             values = { 'username' : message[1] }
  360.                             html = self.encodeurl('http://www.beamng.com/member.php', values)
  361.                             join = self.htmlfind(html, '<dd>', '</dd>')
  362.                             title = self.htmlfind(html, '<title>', '</title>')
  363.                             friends = self.htmlfind(html, '<span class="friends_total">', '</span>')
  364.                             rank = self.htmlfind(html, '<span class="usertitle">', '</span>')
  365.                             if friends == "-1":
  366.                                 if rank == "-1" :
  367.                                     self.say("Account doesn't exist", target)
  368.                                     #self.say((title), target)
  369.                                 else:
  370.                                       self.say('\x02' + (message[1]) + '\x02 joined the forums on \x02' + (join) + '\x02 and is a \x02' + (rank) + '\x02.', target)
  371.                             else:
  372.                                 if rank == "-1" :
  373.                                     self.say("Account doesn't exist", target)
  374.                                     #self.say((title), target)
  375.                                 else:
  376.                                     self.say('\x02' + (message[1]) + '\x02 has \x02' + (friends) + ' \x02friends. \x02' + (message[1]) + '\x02 joined the forums on \x02' + (join) + '\x02 and is a \x02' + (rank) + '\x02.', target)
  377.                      # Now i'm just duplicating bots from #offtopic
  378.                     if command == '!FACT':
  379.                         try:
  380.                             response = urllib2.urlopen('http://numbersapi.com/' + message[1]) # fetches the websites data
  381.                             html = response.read() # saves the data into a string
  382.                             self.say((html), target) # print the fact to irc
  383.                         except:
  384.                             print 'nope'
  385.                     if command == '!REMEMBER':
  386.                       from os import path, access, R_OK
  387.                       remember = "remember/" + (body[0]) + ".txt"
  388.                       if path.isfile(remember) and access((remember), R_OK):
  389.                           self.say('\x02' + (body[0]) + '\x02 already has a definition, remembering yours instead.', target)
  390.                           import os
  391.                           os.remove((remember))
  392.                           length = len(body[0])
  393.                           flength = 10 + (length)
  394.                           remember = open((remember), "ab+")
  395.                           remember.write((ctx['msg'][(flength):]))
  396.                           remember.close()
  397.                       else:
  398.                           length = len(body[0])
  399.                           flength = 10 + (length)
  400.                           remember = open((remember), "ab+")
  401.                           remember.write((ctx['msg'][(flength):]))
  402.                           remember.close()
  403.                           self.say("I'll remember that.", target)
  404.                     def tosay(tosay):
  405.                         self.say((tosay), target)
  406.  
  407. #                    if command == '!CLEVER':
  408. #                        from chatterbotapi import ChatterBotFactory, ChatterBotType
  409. #                        import time
  410. #                        factory = ChatterBotFactory()
  411. #                        bot1 = factory.create(ChatterBotType.CLEVERBOT)
  412. #                        bot1session = bot1.create_session()
  413. #                        bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
  414. #                        bot2session = bot2.create_session()
  415. #                        s = self.delimit(message[1], " ")
  416. #                        s = bot2session.think(s);
  417. #                        time.sleep(2)
  418. #                        two = (s)
  419. #                        self.say((two), target)
  420. #                        s = bot1session.think(s);
  421.                     if command == '!GERMAN':
  422.                         values = { 'src' : 'fr',
  423.                                    'dest' : 'de',
  424.                                    'text' : message[1],
  425.                                    'email' : 'danj.scripter@gmail.com',
  426.                                    'password' : 'five12' }
  427.                         html = self.encodeurl('http://syslang.com/', values)
  428.                         trans = self.htmlfind(html, '<translation>', '</translation>')
  429.                         self.say((trans), target)
  430.                     if command == '!GERMAN2ENGLISH':
  431.                         values = { 'src' : 'de',
  432.                                    'dest' : 'en',
  433.                                    'text' : message[1],
  434.                                    'email' : 'danj.scripter@gmail.com',
  435.                                    'password' : 'five12' }
  436.                         html = self.encodeurl('http://syslang.com/', values)
  437.                         trans = self.htmlfind(html, '<translation>', '</translation>')
  438.                         self.say((trans), target)
  439.                     if command == '!CONVO':
  440.                         try:
  441.                             if fun == 1:
  442.                                 print "doing"
  443.                                 values = { 'say' : message[1],
  444.                                            'bot_id' : '10',
  445.                                            'convo_id' : '661413365323256456' }
  446.                                 html = self.encodeurl('http://api.program-o.com/v2.3.1/chatbot/', values)
  447.                                 say = self.htmlfind(html, 'botsay":"', '"}')
  448.                                 say = urllib.unquote(say)
  449.                                 print (say)
  450.                                 self.say((say), target)
  451.                         except urllib2.HTTPError, error:
  452.                             print error
  453.                         except:
  454.                             print "error:", sys.exc_info()
  455.                     if command == '!RUSSIAN':
  456.                         values = { 'src' : 'fr',
  457.                                    'dest' : 'ru',
  458.                                    'text' : message[1],
  459.                                    'email' : 'danj.scripter@gmail.com',
  460.                                    'password' : 'five12' }
  461.                         html = self.encodeurl('http://syslang.com/', values)
  462.                         trans = self.htmlfind(html, '<translation>', '</translation>')
  463.                         self.say((trans), target)
  464.                     if command == '!GIS':
  465.                             html = self.webrequest("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" + self.delimit(message[1], "%20"))
  466.                             image = self.htmlfind(html, '"unescapedUrl":"', '","')
  467.                             self.say((image), target)
  468.                     if command == '!GOOGLE':
  469.                         if fun == 1:
  470.                             from pygoogle import pygoogle
  471.                             g = pygoogle((self.delimit(message[1], " ")))
  472.                             g.pages = 1
  473.                             say = g.get_urls()
  474.                             say = str(say).split(',')[0]
  475.                             say = say.replace("[u'", "")
  476.                             say = say.replace("'", "")
  477.                             self.say((say), target)
  478.                             if say.find('www.youtube.com/watch?v=') != -1 :
  479.                                 if data.find('results?search') != -1 or data.find('/user') != -1 :
  480.                                     print "nope"
  481.                                 else:
  482.                                     fresh = (say)
  483.                                     try:
  484.                                         html = self.webrequest(fresh)
  485.                                         title = self.htmlfind(html, '<title>', '</title>')
  486.                                         title = title.replace(" - YouTube", "")
  487.                                         user = self.htmlfind(html, '<link itemprop="url" href="http://www.youtube.com/user/', '">')
  488.                                         user = self.ytconstruct(user, ' \x02By:\x02 ')
  489.                                         views = self.htmlfind(html, 'span class="watch-view-count " >', '</span>')
  490.                                         views = views.replace("Aufrufe", "")
  491.                                         #my system isn't German, strip "views" from output as well
  492.                                         views = views.replace("views", "")
  493.                                         views = self.ytconstruct(views, ' \x02Views:\x02 ')
  494.                                         likes = self.htmlfind(html, 'span class="likes-count">', '</span>')
  495.                                         likes2 = float(likes.replace(".", ""))
  496. #                                        likes2 = float(likes.replace(",", ""))
  497.                                         likes = self.ytconstruct(likes, ' \x02Likes:\x02 ')
  498.                                         dislikes = self.htmlfind(html, 'span class="dislikes-count">', '</span>')
  499.                                         dislikes2 = float(dislikes.replace(".", ""))
  500. #                                        dislikes2 = float(dislikes.replace(",", ""))
  501.                                         dislikes = self.ytconstruct(dislikes, ' \x02Dislikes:\x02 ')
  502.                                         date = self.htmlfind(html, 'class="watch-video-date" >', '</span>')
  503.                                         date = self.ytconstruct(date, ' \x02Uploaded:\x02 ')
  504.                                         total = likes2+dislikes2
  505.                                         if total > 0:
  506.                                           final = round(((likes2/total)*100), 2)
  507.                                           final = self.ytconstruct(str(final), ' \x02Recommended:\x02 ')
  508.                                           final = final + '%'
  509.                                         else:
  510.                                           final = ""
  511.                                         print title
  512.                                         print user
  513.                                         views = views.replace('.', ',')
  514.                                         likes = likes.replace('.', ',')
  515.                                         dislikes = dislikes.replace('.', ',')
  516.                                         self.say('\x02\x0301,00You\x0300,04Tube' + '\x0f - \x02Title: \x02' + self.symboldecode(title, 14) + (user) + (date) + (views) + (likes) + (dislikes) + (final), target)
  517.                                         final, likes2, dislikes2 = -1, -1, -1
  518.                                     except urllib2.HTTPError, error:
  519.                                         print error
  520.                                     except:
  521.                                         print "Error:", sys.exc_info()
  522.                                         self.say("\x02Whoops, page error 404, that's bad isn't it? \x02", target)
  523.                     if command == '!RUSSIAN2ENGLISH':
  524.                         values = { 'src' : 'ru',
  525.                                    'dest' : 'en',
  526.                                    'text' : urllib.quote(message[1]),
  527.                                    'email' : 'danj.scripter@gmail.com',
  528.                                    'password' : 'five12' }
  529.                         html = self.encodeurl('http://syslang.com/', values)
  530.                         trans = self.htmlfind(html, '<translation>', '</translation>')
  531.                         self.say((trans), target)
  532.                     if command == '!NORWAY':
  533.                         values = { 'src' : 'fr',
  534.                                    'dest' : 'no',
  535.                                    'text' : urllib.quote(message[1]),
  536.                                    'email' : 'danj.scripter@gmail.com',
  537.                                    'password' : 'five12' }
  538.                         html = self.encodeurl('http://syslang.com/', values)
  539.                         trans = self.htmlfind(html, '<translation>', '</translation>')
  540.                         self.say((trans), target)
  541.                     if command == '!NORWAY2ENGLISH':
  542.                         values = { 'src' : 'no',
  543.                                    'dest' : 'en',
  544.                                    'text' : message[1],
  545.                                    'email' : 'danj.scripter@gmail.com',
  546.                                    'password' : 'five12' }
  547.                         html = self.encodeurl('http://syslang.com/', values)
  548.                         trans = self.htmlfind(html, '<translation>', '</translation>')
  549.                         self.say((trans), target)
  550.                     if command == '!WIKI':
  551.                         try:
  552.                             import re
  553.                             values = { 'search' : message[1],
  554.                                        'go' : 'Go' }
  555.                             html = self.encodeurl("http://en.wikipedia.org/wiki/Special:Search", values)
  556.                             n = self.htmlfind(html, '<p>', '.')
  557.                             n = self.symboldecode(n, 3)
  558.                             q = re.compile(r'<.*?>', re.IGNORECASE)
  559.                             a = re.sub(q, '', n)
  560.                             a = a + '.'
  561.                             if a.find('may refer to') != -1:
  562.                                 whut()
  563.                             self.say((a), target)
  564.                         except urllib2.HTTPError, error:
  565.                             print error
  566.                         except:
  567.                             print "Error:", sys.exc_info()
  568.                             self.say((message[1]) + ' not found.', target)
  569.                     if command == '!RANDOM':
  570.                         seed = self.delimit(message[1], " ")
  571.                         get_data(seed)
  572.                     if command == '!W':
  573.                         if fun == 1:
  574.                             try:
  575.                                 values = { 'query' : message[1] }
  576.                                 html = self.encodeurl("http://www.wund.com/cgi-bin/findweather/getForecast", values)
  577.                                 con = self.htmlfind(html, '<h4>', '</h4>')
  578.                                 temp = self.htmlfind(html, "<h3>\n  <span>", '</span>')
  579.                                 real = self.htmlfind(html, '<h1>', '</h1>')
  580.                                 if con == "-1":
  581.                                     self.say((message[1]) + ': not found', target)
  582.                                 else:
  583.                                     temp = temp.split('.')[0]
  584.                                     f = ((float((temp)) * 9) / 5 + 32)
  585.                                     f = str((f))[:5]
  586.                                     self.say('\x02' + (real) +':\x02 currently: ' + (con) + ', ' + str((temp)) + '°C/' + str((f)) + '°F', target)
  587.                             except urllib2.HTTPError, error:
  588.                                 self.say((message[1]) + ': not found', target)
  589.                                 print error
  590.                             except:
  591.                                 self.say((message[1]) + ': not found', target)
  592.                                 print "Error:", sys.exc_info()
  593.                     if command == '!WHOIS':
  594.                         if fun == 1:
  595.                           remember = "remember/" + (body[0]) + ".txt"
  596.                           from os import path, access, R_OK
  597.                           if path.isfile(remember) and access((remember), R_OK):
  598.                               from os import path, access, R_OK
  599.                           if path.isfile(remember) and access((remember), R_OK):
  600.                               with open ((remember), "r") as yourwho:
  601.                                   with open ((remember), "r") as yourtell:
  602.                                       yourwho2=yourwho.read().replace('\n', ' ')
  603.                                       self.say('\x02' + (body[0]) + '\x02' + (yourwho2), target)
  604.                           else:
  605.                               self.say('\x02' + (body[0]) + '\x02 has no definition!', target)
  606.                     if command == '!T':
  607.                         try:
  608.                             values = { 'query' : message[1] }
  609.                             html = self.encodeurl("http://www.wunderground.com/cgi-bin/findweather/getForecast", values)
  610.                             time = self.htmlfind(html, 'id="infoTime"><span>', '</span>')
  611.                             real = self.htmlfind(html, '<title>', 'Fore')
  612.                             if real == "-1":
  613.                                 self.say((message[1]) + ': not found', target)
  614.                                 print((time))
  615.                             else:
  616.                                 if time == "-1":
  617.                                     time = 'HAMMER TIME!!'
  618.                                 self.say('\x02' + (real) +':\x02 currently: ' + (time), target)
  619.                         except urllib2.HTTPError, error:
  620.                             print error
  621.                         except:
  622.                             print "Error:", sys.exc_info()
  623. #Major issues in this block
  624. #****************************************************************************************
  625.                 if data.find('PRIVMSG') != -1:
  626.                     #try:
  627. #                        import urllib2
  628. #                        import json
  629. #                        single = ctx['msg'].split(' ')[0]
  630. #                        req = urllib2.Request("http://ws.detectlanguage.com/0.2/detect?q=" + (single) + "&key=0708589d1ac3e7304aa3ecb96ed20f68")
  631. #                        opener = urllib2.build_opener()
  632. #                        f = opener.open(req)
  633. #                        json = json.loads(f.read())
  634. #                        json = str((json))
  635. #                        json = json.split("language': u'")[1]
  636. #                        json = json.replace(']','')
  637. #                        json = json.replace('}','')
  638. #                        json = json.replace("'",'')
  639. #                        print json
  640. #                        if json.find('en') != -1:
  641. #                            print 'english'
  642. #                        else:
  643. #                            import urllib2
  644. #                            link = "http://syslang.com/?src=" + (json) + "&dest=en&text=" + (newsay) + "&email=danj.scripter@gmail.com&password=five12"
  645. #                            req = urllib2.Request((link))
  646. #                            req.add_header('User-agent', 'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e')
  647. #                            res = urllib2.urlopen(req)
  648. #                            html = res.read()
  649. #                            begin = html.find('<translation>')
  650. #                            end = html.find('</translation>',begin)
  651. #                            trans = html[begin+len('<translation>'):end].strip()
  652. #                            #self.say((trans), target)
  653. #                    except:
  654. #                        print "unknown language"
  655.                     print "has tell?"
  656.                     from os import path, access, R_OK
  657.                     exist = "tells/" + (nick) + ".txt"
  658.                     if path.isfile(exist) and access((exist), R_OK):
  659.                         print "has tell!"
  660.                         exist = "tells/" + (nick) + ".txt"
  661.                         with open ((exist), "r") as yourtell:
  662.                             print (exist)
  663.                             with open ((exist), "r") as yourtell:
  664.                                 yourtell2=yourtell.read().replace('\n', ' ')
  665.                                 self.send("NOTICE " + (nick) + " " + (yourtell2))
  666.                                 already = "tells/annoy/" + (nick) + ".txt"
  667.                                 import os
  668.                                 os.remove((exist))                                        
  669. #                if data.find('PRIVMSG') != -1:
  670. #                    if data.find('.com') != -1 or data.find('.org') != -1 or data.find('.net') != -1:
  671. #                        try:
  672. #                            urllink = data.split('www.')[1]
  673. #                            if urllink.find(' ') != -1:
  674. #                                urllink = urllink.split(' ')[0]
  675. #                            urllink = 'www.' + urllink
  676. #                            file = open('urls.txt', 'r+')
  677. #                            for line in file:
  678. #                                try:
  679. #                                    if urllink == line.split('-')[0].replace(' ', ''):
  680. #                                        self.say((line).split('- ')[1], target)
  681. #                                        break
  682. #                                    error()
  683. #                                except:
  684. #                                    pass
  685. #                            file = open('urls.txt', 'ab+')
  686. #                            file.write('\n' + (urllink) + ' - ^ This was linked by ' + (ctx['sender']).split('!')[0] + ' already.')
  687. #                            file.close()
  688. #                        except:
  689. #                            pass
  690.                 if data.find('www.youtube.com/watch?v=') != -1 :
  691.                     if data.find('results?search') != -1 or data.find('/user') != -1 :
  692.                         print "nope"
  693.                     else:
  694.                         list = (data).split()
  695.                         for word in list:
  696.                             if 'www.youtube.com' in word :
  697.                                 word1 = word.split()
  698.                                 print word1
  699.  
  700.                                 for fresh in word1:
  701.                                     if 'www.youtube.com' in fresh :
  702.                                         print fresh
  703.                                         if fresh.startswith(':'):
  704.                                             fresh = fresh[1:]
  705.                         try:
  706.                             html = self.webrequest(fresh)
  707.                             title = self.htmlfind(html, '<title>', '</title>')
  708.                             title = title.replace(" - YouTube", "")
  709.                             user = self.htmlfind(html, 'data-name="watch">', '</a>')
  710.                             user = self.ytconstruct(user, ' \x02By:\x02 ')
  711.                             views = self.htmlfind(html, 'span class="watch-view-count">', '</span>')
  712.                             views = views.replace("Aufrufe", "")
  713.                             #my system isn't German, strip "views" from output as well
  714.                             views = views.replace("views", "")
  715.                             views = self.ytconstruct(views, ' \x02Views:\x02 ')
  716.                             likes = self.htmlfind(html, 'span class="likes-count">', '</span>')
  717. #                            likes2 = float(likes.replace(".", ""))
  718.                             likes2 = float(likes.replace(",", ""))
  719.                             likes = self.ytconstruct(likes, ' \x02Likes:\x02 ')
  720.                             dislikes = self.htmlfind(html, 'span class="dislikes-count">', '</span>')
  721. #                            dislikes2 = float(dislikes.replace(".", ""))
  722.                             dislikes2 = float(dislikes.replace(",", ""))
  723.                             dislikes = self.ytconstruct(dislikes, ' \x02Dislikes:\x02 ')
  724.                             date = self.htmlfind(html, '<strong>Uploaded on ', '</strong>')
  725.                             if date == "-1":
  726.                               date = self.htmlfind(html, '<strong>Published on ', '</strong>')
  727.                             date = self.ytconstruct(date, ' \x02Uploaded:\x02 ')
  728.                             total = likes2+dislikes2
  729.                 if total > 0:
  730.                               final = round(((likes2/total)*100), 2)
  731.                               final = self.ytconstruct(str(final), ' \x02Recommended:\x02 ')
  732.                               final = final + '%'
  733.                 else:
  734.                   final = ""
  735.                             print title
  736.                             print user
  737.                             views = views.replace('.', ',')
  738.                             likes = likes.replace('.', ',')
  739.                             dislikes = dislikes.replace('.', ',')
  740.                             self.say('\x02\x0301,00You\x0300,04Tube' + '\x0f - \x02Title: \x02' + self.symboldecode(title, 14) + (user) + (views) + (likes) + (dislikes) + (final), target)
  741.                             final, likes2, dislikes2 = -1, -1, -1
  742.                         except urllib2.HTTPError, error:
  743.                             print error
  744.                         except:
  745.                             print "Error:", sys.exc_info()
  746.                 if links == 1:
  747.                     if data.find('http://') != -1 :
  748.                         list = (data).split(" ")
  749.                         for word in list:
  750.                             if 'http://' in word :
  751.                                 word1 = word.split(" ")
  752.                                 print word1
  753.                                 for fresh in word1:
  754.                                     if 'http://' in fresh :
  755.                                         print fresh
  756.                                         if fresh.startswith(':'):
  757.                                             fresh = fresh[1:]
  758.                         try:
  759.                             html = self.webrequest(fresh)
  760.                             title = self.htmlfind(html, '<title>', '</title>')
  761.                             title = self.symboldecode(title, 14)
  762.                             if title == "-1":
  763.                                 print "nope"
  764.                             else :
  765.                                 if fresh.find('youtube') != -1 or fresh.find('.jpeg') != -1:
  766.                                     print "youtube link, or something idk screw you"
  767.                                 else:
  768.                                     self.say('Title: \x02' + (title) + '\x02', target)
  769.                         except urllib2.HTTPError, error:
  770.                             print error
  771.                         except:
  772.                             print "Error:", sys.exc_info()
  773.                 html = None
  774. #****************************************************************************************
  775.     def send(self, msg):
  776.         print "I>",msg
  777.         self.socket.send(msg+"\r\n")
  778.     def say(self, msg, to):
  779.         self.send("PRIVMSG %s :%s" % (to, msg))
  780.     def delimit(self, string, delimiter):
  781.         delimited = string.replace(' ', delimiter).lower()
  782.         return delimited
  783.     def format(self, string):
  784.         if len(string) > 0:
  785.           nickname = "\x02" + string + ":\x02 "
  786.         else:
  787.           nickname = ""
  788.         return nickname
  789.     def encodeurl(self, link, values):
  790.         headers = { 'User-Agent' : 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Win64; x64; Trident/5.0)',
  791.                     'Accept-Language' : 'en-US' }
  792.         values = urllib.urlencode(values)
  793.         req = urllib2.Request(link, values, headers)
  794.         html = self.webrequest(req)
  795.         return html
  796.     def webrequest(self, link):
  797.         response = urllib2.urlopen(link) #link in this case could refer to the encoded URL data from function above
  798.         html = response.read()
  799.         return html
  800.     def htmlfind(self, html, begin, end):
  801.         string = html[html.find((begin))+len(begin):html.find((end), html.find(begin))]
  802.         if html.find((begin)) == -1:
  803.           string = "Lost data"
  804.         if type(string) == str:
  805.           string = string.strip()
  806.     return string
  807.     def ytreplace(self, string, period):
  808.         chars = { "<" : "", ">" : "", " " : "", "/" : "", "\n" : "" }
  809.         for key,value in chars.item():
  810.           string = string.replace(key, value)
  811.         if period == 1:
  812.             string = string.replace(".", ",")
  813.         return string
  814.     def ytconstruct(self, string, prefix):
  815.         if string != "-1":
  816.             string = prefix + string
  817.         else:
  818.             string = ""
  819.         return string
  820.     def symboldecode(self, string, option):
  821.         htmlcodes = { '&quot;' : '"', '&amp;' : '&', '&lt;' : '<', '&gt;' : '>', '&nbsp;' : ' ', '&iexcl;' : '¡', '&cent;' : '¢', '&pound;' : '£', '&curren;' : '¤', '&yen;' : '¥', '&brvbar;' : '¦', '&sect;' : '§', '&uml;' : '¨', '&copy;' : '©', '&ordf;' : 'ª', '&laquo;' : '«', '&not;' : '¬', '&reg;' : '®', '&macr;' : '¯', '&deg;' : '°', '&plusmn;' : '±', '&sup2;' : '²', '&sup3;' : '³', '&acute;' : '´', '&micro;' : 'µ', '&para;' : '¶', '&middot;' : '·', '&cedil;' : '¸', '&sup1;' : '¹', '&ordm;' : 'º', '&raquo;' : '»', '&frac14;' : '¼', '&frac12;' : '½', '&frac34;' : '¾', '&iquest;' : '¿' }
  822.         removechars = { "<" : "", ">" : "", " " : "", "/" : "", "\n" : "" }
  823.         formatcodes = { '<b>' : '\x02', '</b>' : '\x02', '<i>' : '\\x09', '</i>' : '\\x09', '<u>' : '\x15', '</u>' : '\x15' }
  824.         htmlnum = { '&#32;' : ' ', '&#33;' : '!','&#34;' : '\"', '&#35;' : '#', '&#36;' : '$', '&#37;' : '%', '&#38;' : '&', '&#39;' : "\'", '&#40;' : '(', '&#41;' : ')', '&#42;' : '*', '&#43;' : '+', '&#44;' : ',', '&#45;' : '-', '&#46;' : '.', '&#47;' : '/', '&#58;' : ':', '&#59;' : ';', '&#60;' : '<','&#61;' : '=','&#62;' : '>', '&#63;' : '?', '&64;' : '@', '&#91;' : '[', '&#92;' : '\\', '&#93;' : ']', '&#94;' : '^', '&#95;' : '_', '&#96;' : '`', '&#123;' : '{', '&#124;' : '|', '&#125;' : '}', '&#126;' : '~', '&#160;' : ' ', '&#161;' : '¡', '&#162;' : '¢', '&#163;' : '£', '&#164;' : '¤', '&#165;' : '¥', '&#166;' : '¦', '&#167;' : '§', '&#168;' : '¨', '&#169;' : '©', '&#170;' : 'ª', '&#171;' : '«', '&#172;' : '¬', '&#173;' : '­', '&#174;' : '®','&#175;' : '¯', '&#176;' : '°', '&#177;' : '±', '&#178;' : '²', '&#179;' : '³', '&#180;' : '´', '&#181;' : 'µ', '&#182;' : '¶', '&#183;' : '·', '&#184;' : '¸', '&#185;' : '¹', '&#186;' : 'º', '&#187;' : '»', '&#188;' : '¼', '&#189;' : '½', '&#190;' : '¾', '&#191;' : '¿' }
  825.         combined = ( None, htmlcodes, removechars, formatcodes, htmlnum)
  826.         print option
  827.         if len(str(abs(option))) == 1:
  828.           print combined[option]
  829.           repldict = combined[option]
  830.         elif len(str(abs(option))) > 1 and len(str(abs(option))) < 10:
  831.           firstopt = option / 10
  832.           secondopt = option % 10
  833.           repldict = combined[firstopt]
  834.           repldict.update(combined[secondopt])
  835.         elif len(str(abs(option))) > 10 and len(str(abs(option))) < 1000:
  836.           thirdopt = option % 10
  837.           firstopt = option / 100
  838.           secondopt = (option/10) % 10
  839.           repldict = combined[firstopt]
  840.           repldict.update(combined[secondopt])
  841.           repldict.update(combined[thirdopt])
  842.         else:
  843.           print "invalid option"
  844.         for key,value in repldict.items():
  845.           string = string.replace(key, value)
  846.         return string
  847.     def perform(self):
  848.         #self.send("PRIVMSG R : Register <>")
  849.         self.send("PRIVMSG R : Login <>")
  850.         self.send("MODE %s +x" % self.nickname)
  851.         for c in self.channels:
  852.             self.send("JOIN %s" % c)
  853. IRCClient()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement