-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtroll.py
33 lines (27 loc) · 1.17 KB
/
troll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import unicode_literals
import Queue
import requests
import mythread
import utils
import time
class troll(mythread.Thread):
def __init__(self, Target, sock,channel):
mythread.Thread.__init__(self)
self.queue = Queue.Queue()
self.sock = sock
self.target = Target
self.channel=channel
def init(self):
utils.print_message("I can help you {} :)".format(self.target), "PRIVMSG", self.sock, self.target)
def main(self):
pseudo, msg = self.queue.get()
if pseudo == self.target:
res=self.get_citation()
utils.print_message("{}=>{}".format(self.target,msg).encode(errors="replace"), "PUBMSG", self.sock, channel=self.channel)
utils.print_message("{}<={}".format(self.target,res).encode(errors="replace"), "PUBMSG", self.sock,channel=self.channel)
time.sleep(0.1*len(res))
utils.print_message(res.encode(errors="replace"), "PRIVMSG", self.sock, self.target)
@staticmethod
def get_citation():
r = requests.get("http://www.quotationspage.com/random.php3")
return utils.parse_html_balise("a", utils.parse_html_balise("dt", r.text))