Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ch
- import requests
- from bs4 import BeautifulSoup
- import urllib
- import time
- import os
- import threading
- import random
- import re
- def compile(ster):
- with open("ban.txt") as e:
- r=e.read().splitlines()
- r = filter(None, r)
- final=list(set(r))
- ster=ster.lower()
- for item in final:
- if item in ster or item.capitalize() in ster or item.lower() in ster:
- ster=ster.replace(item,"")
- ster=ster.replace("."," ")
- y=ster.split(" ")
- print y
- for item in y:
- if re.search(r'[12]\d{3}', item):
- target_ibdex = y.index(item)
- ster=" ".join(y[:target_ibdex+1])
- break
- return ster
- def getmovie():
- s = requests.Session()
- #VLC password entered here.
- s.auth = ('', 'pass')# Username is blank, just provide the password
- r = s.get('http://localhost:8080/requests/status.xml', verify=False)
- #print r.text
- soup=BeautifulSoup(r.text,"html.parser")
- result = soup.find('info', {'name' :'filename'}).text
- #grabbing VLC filename of Movie
- #print result
- res=os.path.splitext(result)
- s.close()
- #getting IMDB results
- g=compile(res[0])
- print g
- url="http://www.imdb.com/find?ref_=nv_sr_fn&q="+g+"&s=all"
- headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
- t = requests.get(url,headers=headers)
- soup = BeautifulSoup(t.content,"html.parser")
- try:
- result = soup.find('td', {'class' :'result_text'}).find('a')['href']
- link="http://www.imdb.com"+result
- #returns the IMDB link if found.
- return link
- except:
- return "No Result Found"
- class bot(ch.RoomManager):
- #the bot starts
- def onInit(self):
- #self.setNameColor("FFFFFF")
- #self.setFontColor("FFFFFF")
- self.setFontFace("Times New Roman")
- self.setFontSize(19)
- #when someone joins
- def onJoin(self, room, user, puid):
- room.message(welcome(user.name))
- #on connectivity
- def onConnect(self, room):
- print("Connected to "+room.name)
- room.message("sup")
- #while True:
- # room.message("Its an Hourly Message..!!")
- # time.sleep(60)
- def onReconnect(self, room):
- print("Reconnected")
- #when someone messages in
- def onMessage(self, room, user, message):
- print("[{0}] {1}: {2}".format(room.name, user.name.title(), message.body))
- #enter imgur links here
- links_to_imgur=["http://i.imgur.com/brqdwST.png","http://i.imgur.com/95wH1fX.jpg","http://i.imgur.com/FqmzRZG.png","http://i.imgur.com/iZzzIl1.png","http://i.imgur.com/POExwF3.jpg","http://i.imgur.com/Jev5ygL.png","http://i.imgur.com/VXCOhQV.png,","http://i.imgur.com/MQcLZfr.png","http://i.imgur.com/rY50611.png","http://i.imgur.com/S7wURDd.png","http://i.imgur.com/brqdwST.png","http://i.imgur.com/l9COjSF.png","http://i.imgur.com/ejMxc1h.png","http://i.imgur.com/APnh8u5.png","http://i.imgur.com/bMvegoz.png","http://i.imgur.com/tmKfD71.jpg","http://i.imgur.com/GUOAfvC.png","http://i.imgur.com/nW0dsaB.jpg","http://i.imgur.com/HQPI4w2.png","http://i.imgur.com/4ALL16Y.png"]
- #list of words to be scanned in messages
- banned=["test1","test2"]
- for item in banned:
- if item in message.body:
- #response to the words if found
- room.message("Banned word found.")
- try:
- cmd, args = message.body.split(" ", 1)
- except:
- cmd, args = message.body, ""
- #print args
- if cmd[0] == "/":
- prfx = True
- cmd = cmd[1:]
- cmd.lower()
- '''list of all commands. you can create one in the same format as below.
- '''
- if cmd=="movie":
- room.message("Looking IMDB")
- #print getmovie()
- room.message(getmovie())
- #create a command hello
- elif cmd=="phrasing":
- room.message("http://i.imgur.com/i2yYun3.gif")
- elif cmd=="help":
- room.message("FCTV Bot Command list")
- room.message("./phrasing, ./blackhole, ./imdb, ./request :Request a movie, ./quote, ./burger, ./bigguy")
- elif cmd=="blackhole":
- room.message("http://i.imgur.com/XFwsz8a.jpg, "+user.name.title())
- elif cmd=="request":
- room.message("Sure, ill try to stream that soon. "+user.name.title())
- a=open("request.txt","a")
- a.write(args+"\n")
- a.close()
- elif cmd=="imgur":
- random.shuffle(links_to_imgur)
- g=random.choice(links_to_imgur)
- room.message(g)
- elif cmd=="burger":
- room.message("*burger*")
- elif cmd=="imdb":
- room.message("Looking IMDB")
- #print getmovie()
- room.message(getmovie())
- elif cmd=="bigguy":
- room.message("For you.")
- else:
- room.message("Incorrect Command.")
- else:
- prfx = False
- #credentials
- rooms = ["troublesomegentlemen"]
- username = "FilthyAndroid"
- password = "qwerqwer1"
- bot.easy_start(rooms,username,password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement