예제 #1
0
	def Favorite_add(self,url):
		data='{"token":"%s","link":"%s"}'%(self.get_token(),url)
		response=self.fetch('https://www.fshare.vn/api/fileops/AddFavorite',data)
		if response and response.status==200:
			result=True;utils.mess(u'Add a item to MyFshare Favorite success','Fshare.vn')
		else:result=False;utils.mess(u'Add a item to MyFshare Favorite fail!','Fshare.vn')
		return result
예제 #2
0
파일: bot.py 프로젝트: gachiHub/twitchBOTd
def main():
    s = socket.socket()
    s.connect((config.HOST, config.PORT))
    s.send("PASS {}\r\n".format(config.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
    s.send("JOIN #{}\r\n".format(config.CHAN).encode("utf-8"))

    chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    #utils.mess(s, "Zdarova")

    thread.start_new_thread(utils.fillOpList, ())
    while True:
        response = s.recv(1024).decode("utf-8")
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("POND :tmi.twitch.tv\r\n".encode("utf-8"))
        else:
            username = re.search(r"\w+", response).group(0)
            message = chat_message.sub("", response)
            print(response)

            if message.strip() == "!time":
                utils.mess(s, "Стрим идёт уже " + time.strftime("%A %B %d %Y"))
            if message.strip() == "!randomemote":
                utils.mess(s, )
        sleep(1)
예제 #3
0
def main():
    s = socket.socket()
    s.connect((config.HOST, config.PORT))
    s.send("PASS {}\r\n".format(config.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
    s.send("JOIN #{}\r\n".format(config.CHAN).encode("utf-8"))

    chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    utils.mess(s, "What's up guys?")

    threading._start_new_thread(utils.fill0plist())

    while True:
        response = s.recv(1024).decode("utf-8")
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("POND :tmi.twitch.tv\r\n".encode("utf-8"))
        else:
            message = chat_message.sub("", response)
            print(response)

            if message.strip() == "!time":
                utils.mess(
                    s, "it's currently: " +
                    time.strftime("%I:%M %p %Z on %A %B %d %Y"))

        sleep(1)
예제 #4
0
	def myFshare_remove(self,url):
		id=[s[2] for s in self.get_folder('https://www.fshare.vn/folder/'+self.myFshare)['items'] if url==s[1]]
		id=id[0] if id else '';data='{"token":"%s","items":["%s"]}'%(self.get_token(),id.strip())
		response=self.fetch('https://www.fshare.vn/api/fileops/delete',data)
		if response and response.status==200:result=True;utils.mess(u'Remove a item from MyFshare success','Fshare.vn')
		else:result=False;utils.mess(u'Remove a item from MyFshare fail!','Fshare.vn')
		return result
예제 #5
0
	def myFshare_rename(self,url,new_name):
		id=[s[2] for s in self.get_folder('https://www.fshare.vn/folder/'+self.myFshare)['items'] if url==s[1]]
		id=id[0] if id else '';data='{"token":"%s","new_name":"%s","file":"%s"}'%(self.get_token(),new_name,id)
		response=self.fetch('https://www.fshare.vn/api/fileops/rename',data)
		if response and response.status==200:result=True;utils.mess(u'Rename a item in MyFshare success','Fshare.vn')
		else:result=False;utils.mess(u'Rename a item in MyFshare fail!','Fshare.vn')
		return result
예제 #6
0
	def get_maxlink(self,url):
		response=self.fetch(url);result=pw=None
		if not response:print 'Not response'
		elif response.status==302:result=response.headers['location']
		elif response.status==200:
			if re.search('<title>.*Lỗi 404.*</title>|"index-404"',response.body):
				utils.mess(u'Tập tin quý khách yêu cầu không tồn tại!','Fshare.vn');result='fail'
			elif 'sử dụng nhiều địa chỉ IP' in response.body:
				utils.mess(u'Quý khách đang sử dụng nhiều địa chỉ IP để tải xuống!','Fshare.vn',10000)
				result='fail'
			elif re.search('<i class="fa fa-star">',response.body):utils.mess('Your Fshare acc is FREE','Fshare.vn')
			
			if re.search('class="fa fa-lock"',response.body):
				pw=utils.get_input(u'Hãy nhập: Mật khẩu tập tin')
				if pw:
					try:
						data={'fs_csrf':utils.xsearch('value="(.+?)" name="fs_csrf"',response.body),
						'DownloadForm[pwd]':pw,'ajax':'download-form','DownloadForm[linkcode]':url.split('/')[4]}
						response=self.fetch('https://www.fshare.vn/download/get',data).json
					except:response={}

					if not response:utils.mess(u'Get maxspeed link fail!','Fshare.vn');result='fail'
					elif response.get('url'):result=response.get('url')
					elif response.get('DownloadForm_pwd'):utils.mess(u'Mật khẩu không chính xác!','Fshare.vn')
					else: print response
			elif re.search('action="/download/get"',response.body):
				href='https://www.fshare.vn'+utils.xsearch('action="(/download/get)"',response.body)
				fs_csrf=utils.xsearch('value="(.+?)" name="fs_csrf"',response.body)
				downloadForm=utils.xsearch('id="DownloadForm_linkcode" type="hidden" value="(.+?)"',response.body)
				data={'fs_csrf':fs_csrf,'DownloadForm[pwd]':'','DownloadForm[linkcode]':downloadForm,
						'ajax':'download-form','undefined':'undefined'}
				response=self.fetch(href,data)
				try:result=response.json.get('url')
				except:pass
예제 #7
0
	def Favorite_remove(self,name):
		data='{"token":"%s","items":["%s"],"status":0}'%(self.get_token(),name)
		response=self.fetch('https://www.fshare.vn/api/fileops/ChangeFavorite',data)
		if response and response.status==200:
			result=True;utils.mess(u'Remove a item from MyFshare Favorite success','Fshare.vn')
		else:result=False;utils.mess(u'Remove a item from MyFshare Favorite fail!','Fshare.vn')
		return result
예제 #8
0
	def action_bookmark(self, url,action):#add_bookmark/remove_bookmark
		id=utils.xsearch('_(\d+?)/',url)
		if id:
			url='http://phim3s.net/ajax/member/%s/?film_id=%s'%(action,id)
			response=self.fetch(url)
			try:response=response.json
			except:response={}
			utils.mess(u'%s'%response.get('message','%s thất bại !'%action),'Phim3s.net bookmark')
			self.fetch('http://phim3s.net/member/logout/')
예제 #9
0
	def remove_folder(self,parent_folder,folder_id):
		data='{"token":"%s","items":["%s"]}'%(self.get_token(),folder_id)
		self.hd['Referer']='https://www.fshare.vn/home/xshare_favourite'
		response=self.fetch('https://www.fshare.vn/api/fileops/delete',data)
		try:result=response.json;result_code=result.get('code')
		except:result_code=0
		if result_code==200:
			utils.mess(result.get('msg'),'Fshare.vn');result='ok'
		else:utils.mess(u'Xóa mục thất bại','Fshare.vn');result=''
		return result
예제 #10
0
	def add_folder(self,folder_name,in_dir_id='0'):
		token=self.get_token()
		data='{"token":"%s","name":"%s","in_dir":"%s"}'%(token,folder_name,in_dir_id)
		response=self.fetch('https://www.fshare.vn/api/fileops/createFolder',data)
		try:result=response.json;result_code=result.get('code')
		except:result_code=0
		if result_code==200:
			utils.mess(result.get('msg')+' - '+result.get('folder',{}).get('name'),'Fshare.vn')
			result=result.get('folder',{}).get('linkcode')
		else:utils.mess(u'Add folder fail !','Fshare.vn');result=''
		return result
예제 #11
0
	def upload_file(self,fn):#Chua xong
		size=os.path.getsize(fn);name=os.path.basename(fn);path='/'
		session_id=utils.xsearch('session_id=(.+?)\W',str(self.hd))
		data='{"SESSID":"%s","name":"%s","path":"%s","secured":"1","size":"%d","token":"%s"}'%(session_id,name,path,size,self.get_token())
		response=self.fetch('https://www.fshare.vn/api/session/upload',data)
		print 'a',data
		if response and response.status==200:
			print response.json['location']
			try:response=urlfetch.fetch(response.json['location'].replace('http:','https:'),headers=self.hd,data=data)#files=fn)
			except:response= None
			#response=self.fetch(response.json['location'],files=fn)
			if response and response.status==200:
				print response.json
				result=True;utils.mess(u'Upload file to MyFshare success','Fshare.vn')
예제 #12
0
파일: bot.py 프로젝트: Brigsk/twitchbot
def main():
    s = socket.socket()
    s.connect((config.HOST, config.PORT))
    s.send("PASS {}\r\n".format(config.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
    s.send("JOIN {}\r\n".format(config.CHAN).encode("utf-8"))

    chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    utils.mess(s,"Sup, superhumans")

    _thread.start_new_thread(utils.fill0pList, ())
    while True:
        response = s.recv(1024).decode("utf-8")
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("POND  :tmi.twitch.tv\r\n".encode("utf-8"))
        else:
            username = re.search(r"\w+", response).group(0)
            message = chat_message.sub("", response)
            print(response)

            if message.strip() == "!time":
                utils.mess(s, "it's currently " + time.strftime("%I:%M %p %Z on %A %B %d %Y"))
            if message.strip() == "!messages":
                utils.mess(s, "Do something ubermenshen!")
                utils.mess(s, "Go cry over a horse")
        sleep(1)
예제 #13
0
def main():
    s = socket.socket()
    s.connect((config.HOST, config.PORT))
    s.send("PASS {}\r\n".format(config.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
    s.send("JOIN #{}\r\n".format(config.CHAN).encode("utf-8"))

    chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    utils.mess(s, "What is even up, dogs?")

    thread.start_new_thread(utils.fillOpList, ())
    while True:
        response = s.recv(1024).decode("utf-8")
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("POND :tmi.twitch.tv\r\n".encode("utf-8"))
        else:
            username = re.search(r"\w+", response).group(0)
            message = chat_message.sub("", response)
            print(response)


            if message.strip() == "!time":
                utils.mess(s, "it's currently: " + time.strftime("%I:%M %p %Z on %A %B %d %Y"))
            if message.strip() == "!messages" and utils.isOp(username):
                utils.mess(s, "Do something awesome!")
                utils.mess(s, "Go to youtube.com/winderton and click the subscribe button there!")
        sleep(1)
예제 #14
0
	def myFshare_add(self,url,name):
		if not self.myFshare:utils.mess(u'Hãy set "Thư mục chia sẻ của tôi trên Fshare!"','myFshare');return
		id=url.split('/')[4]
		if [s for s in self.get_folder('https://www.fshare.vn/folder/'+self.myFshare)['items'] if id in s[0]]:
			utils.mess(u'This item already in MyFshare!','Fshare.vn');return
		token=self.get_token();name=id+('FOLDER ' if 'folder' in url else 'FILE ')+name
		data='{"token":"%s","name":"%s","in_dir":"%s"}'%(token,name,self.myFshare)
		response=self.fetch('https://www.fshare.vn/api/fileops/createFolder',data)
		if response and response.status==200:utils.mess(u'Add a item to MyFshare success','Fshare.vn')
		else:utils.mess(u'Add a item to MyFshare fail!','Fshare.vn')
예제 #15
0
def main():
    s = socket.socket()
    s.connect((twitch.HOST, twitch.PORT))
    s.send("PASS {}\r\n".format(twitch.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(twitch.NICK).encode("utf-8"))
    s.send("JOIN #{}\r\n".format(twitch.CHAN).encode("utf-8"))
    #s.send("JOIN #{}\r\n".format("sgtgrafoyni").encode("utf-8"))

    chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    utils.mess(s, "Здрова, Всем! KonCha <3")

    _thread.start_new_thread(utils.fillOpList, ())
    #_thread.start_new_thread(waitCLI, (s,))
    while True:
        response = s.recv(1024).decode("utf-8")
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8"))
        else:
            username = re.search(r"\w+", response).group(0)
            message = chat_message.sub("", response)
            message = message.lower()
            print(username + ": " + message)
            #print(response)
            if (message.find(twitch.NICK.lower()) != -1 and
                (message.find("привет") != -1 or message.find("ку") != -1
                 or message.find("здорова") != -1
                 or message.find("приветик") != -1
                 or message.find("здравствуйте") != -1
                 or message.find("хай") != -1 or message.find("хелоу") != -1
                 or message.find("хеллоу") != -1 or message.find("hi") != -1
                 or message.find("йоу") != -1 or message.find("yo") != -1
                 or message.find("heyguys") != -1 or message.find("hey") != -1
                 or message.find("koncha") != -1
                 or message.find("hello") != -1)):
                if username != "tmi":
                    sleep(2)
                    utils.hello(s, username)
                #:[email protected] PRIVMSG #xpyctee:
            if message.strip() == "!hi":
                utils.hello(s, username)
            if message.strip() == "!roll":
                utils.mess(s, f"{username} выкинул: {str(randint(1, 6))}")
            if message.strip() == "!банкет":
                utils.mess(
                    s,
                    f"{username} накрыл стол для чатика из шашлычка, картошечки, грибочков и пыва panicBasket TakeNRG"
                )
            if message.strip() == "!смех":
                utils.mess(s, f"{username} ХаХа-ХаХа")
        sleep(1)
예제 #16
0
def main():
    s = socket.socket()
    s.connect((config.HOST, config.PORT))
    s.send("PASS {}\r\n".format(config.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
    s.send("JOIN #{}\r\n".format(config.CHAN).encode("utf-8"))

    chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    utils.mess(s, "Hello world!")

    thread.start_new_thread(utils.fill_op_list, ())
    while True:
        # Size of the bot = 1024 bytes
        response = s.recv(1024).decode("utf-8")
        if response == "PING :tmi.twitch.tv\r\n":
            s.send("POND :tmi.twitch.tv\r\n".encode("utf-8"))
        else:
            username = re.search(r"\w+", response).group(0)
            message = chat_message.sub("", response)
            print(response)

            if message.strip() == "!time":
                utils.mess(
                    s, "it's currently " +
                    time.strftime("%I:%M %p %Z on %A %B %d %Y"))
            if message.strip() == "!messages" and utils.is_op(username):
                utils.mess(s, "Hello world!")
        sleep(1)
예제 #17
0
    def getLinkFree(self, url):
        from utils import xget
        import urllib
        data = urllib.urlencode({"url": url, "token": self.getToken()})
        b = xget('http://ycofo.xyz/fshare.php', data=data)
        if not b:
            b = xget('http://xshare.eu5.org/fshare.php', data=data)

        if b:
            try:
                j = json.loads(b.read())
            except:
                j = {}
        else:
            j = {}

        if j.get("msg"):
            mess(j.get("msg"))

        link = j.get("location", "")

        if link == "Copy":
            mess(
                "Đây là bản copy của [COLOR red][B]Xshare[/COLOR] [COLOR green]XBMC[/COLOR] [COLOR blue]HDVideo[/B][/COLOR]"
            )
            link = ""
        elif link:
            self.acc = j.get("user", "")
            if j.get("session_id") and j.get("token"):
                data = u2s(
                    j.get("session_id") + "-" + j.get("token") + "-" +
                    self.acc + "-" + j.get("key", ""))
                xrw('newfshare.cookie', data)

            if self.acc:
                self.thanks(u2s(self.acc))

        return link
예제 #18
0
	def login(self,username,password):
		response = self.fetch('https://www.fshare.vn/login')
		if not response or response.status!=200:utils.mess('Connect to fshare.vn fails','Fshare.vn')
		else:
			data = {"LoginForm[email]":username,"LoginForm[password]":password,
				"fs_csrf":utils.xsearch('value="(.+?)" name="fs_csrf"',response.body)}
			response = self.fetch('https://www.fshare.vn/login',data)
			if response and response.status==302:utils.mess(u'Login thành công','Fshare.vn');self.logged='success'
			else:utils.mess(u'Login không thành công!','Fshare.vn')
예제 #19
0
	def get_maxlink(self,url):
		response=self.fetch(url);result=pw=None
		if not response:print 'Not response'
		elif response.status==302:result=response.headers['location']
		elif response.status==200:
			if re.search('<title>.*Lỗi 404.*</title>|"index-404"',response.body):
				utils.mess(u'Tập tin quý khách yêu cầu không tồn tại!','Fshare.vn');result='fail'
			elif re.search('<i class="fa fa-star">',response.body):utils.mess('Your Fshare acc is FREE','Fshare.vn')
			
			if re.search('class="fa fa-lock"',response.body):pw=utils.get_input(u'Hãy nhập: Mật khẩu tập tin')
			if pw:
				try:
					data={'fs_csrf':utils.xsearch('value="(.+?)" name="fs_csrf"',response.body),
					'DownloadForm[pwd]':pw,'ajax':'download-form','DownloadForm[linkcode]':url.split('/')[4]}
					response=self.fetch('https://www.fshare.vn/download/get',data).json
				except:response={}

				if not response:utils.mess(u'Get maxspeed link fail!','Fshare.vn');result='fail'
				elif response.get('url'):result=response.get('url')
				elif response.get('DownloadForm_pwd'):utils.mess(u'Mật khẩu không chính xác!','Fshare.vn')
				else: print response
예제 #20
0
	def myFshare_upload(self,name,size,content):
		response=self.fetch('https://www.fshare.vn/home');result=False
		if not response or response.status!=200:
			content=self.fetch('https://www.fshare.vn/home')
			if not response or response.status!=200:utils.mess(u'Get home page fail!','Fshare.vn');return result
		token=utils.xsearch('data-token="(.+?)"',response.body)
		path=utils.xsearch('data-id="%s" path-origin = "" data-path="(.+?)"'%self.myFshare,response.body)
		SESSID=self.session.cookies.get('session_id')
		data='{"SESSID":"%s","name":"%s","size":"%s","path":"%s","token":"%s","secured":1}'%(
			SESSID,name,size,path,token);print data
		response=self.fetch('https://www.fshare.vn/api/session/upload',data)
		if response and response.status==200:
			response=self.fetch(response.json['location'],content)
			if response and response.status==200:result=True;utils.mess(u'Upload file to MyFshare success','Fshare.vn')
		if result is False:utils.mess(u'Upload file to MyFshare fail!','Fshare.vn');print response.status
		return result
예제 #21
0
    def login(self, user, passwd):
        data = '{"app_key" : "%s", "user_email" : "%s", "password" : "%s"}'
        data = data % (self.key, user, passwd)
        result = self.results("https://api2.fshare.vn/api/user/login",
                              data=data)

        if result.get("code", 0) == 200:
            if self.vip(result.get("session_id")):
                self.session_id = result.get("session_id")
                self.token = result.get("token")
                self.hd = {'Cookie': 'session_id=' + self.session_id}
                xrw('newfshare.cookie',
                    self.session_id + "-" + self.token + "--" + self.key)
                mess("Login thành công", "Fshare.vn")

            else:
                mess("Acc của bạn hết hạn VIP", "Fshare.vn")
        else:
            mess("Login không thành công!", "Fshare.vn")
예제 #22
0
 def thanks(self, acc):
     mess("Cảm ơn: [COLOR cyan]%s[/COLOR] đã hỗ trợ xem phim này" % acc)
예제 #23
0
def newMessageFromChat(s, username, message):  #s = socket
    # add command like !time
    if message.strip() == "!armletmetr":
        utils.mess(
            s, "Твой армлет: " + str(random.randint(8, 25)) +
            " см длинной SeemsGood ")

    if (message.strip() == "!time"):
        utils.mess(s, "У меня сейчас " + time.strftime('%d/%m/%Y %H:%M:%S'))

    if (message.strip() == "!botinfo"):
        utils.mess(s, 'Личный аниме бот 02, ня')

    if (message.strip() == "!девочка"):
        utils.mess(s, 'https://www.youtube.com/watch?v=Kkgu4lgv3HM')

    if ("!addgood" in message.strip()):
        users = utils.getUsersFromString(message.strip())
        datamanager.addToGoodPerson(users)

    if ("!deletegood" in message.strip()):
        users = utils.getUsersFromString(message.strip())
        datamanager.deleteFromGoodPerson(users)

    if ("!goodpersons" in message.strip()):
        users = datamanager.getListFromJson(datamanager.GOODPERSONS)
        if (len(users) == 0):
            utils.mess(s, "К сожалению, на этом стриме ещё нет хороших людей")
        else:
            utils.mess(s, "Список норм челов: " + ' '.join(users))

    if ("!addfagot" in message.strip()):
        users = utils.getUsersFromString(message.strip())
        datamanager.addToFagotPerson(users)

    if ("!deletefagot" in message.strip()):
        users = utils.getUsersFromString(message.strip())
        datamanager.deleteFromFagotPerson(users)

    if ("!fagotpersons" in message.strip()):
        users = datamanager.getListFromJson(datamanager.FAGOTPERSONS)
        if (len(users) == 0):
            utils.mess(s, "К сожалению, на этом стриме ещё нет плохих людей")
        else:
            utils.mess(s, "Список уебанов: " + ' '.join(users))

    if (message.strip() == "!help"):
        string = "Мой хозяин (извращенец) научил меня только этому: "
        string += " ".join([
            "!armletmetr", "!time", "!addgood", "!deletegood", "!goodpersons",
            "!addfagot", "!deletefagot", "!fagotpersons"
        ])
        utils.mess(s, string)
예제 #24
0
def waitCLI(s):
    cliMsg = input()
    utils.mess(s, f"{cliMsg}")
    waitCLI(s)
예제 #25
0
	def get_token(self):
		response=self.fetch('https://www.fshare.vn/home')
		if not response or response.status!=200:
			content=self.fetch('https://www.fshare.vn/home')
			if not response or response.status!=200:utils.mess(u'Get home page fail!','Fshare.vn');return ''
		return utils.xsearch('data-token="(.+?)"',response.body)
예제 #26
0
	def fpt_play_add(self,name='FPT_Play_Favorite'):
		token=self.get_token()
		data='{"token":"%s","name":"%s","in_dir":"%s"}'%(token,name,'0')
		response=self.fetch('https://www.fshare.vn/api/fileops/createFolder',data)
		if response and response.status==200:utils.mess(u'Add a item to MyFshare success','Fshare.vn')
		else:utils.mess(u'Add a item to MyFshare fail!','Fshare.vn')
예제 #27
0
	def login(self, username, password):
		data={'username':username,'password':password}
		response=self.fetch('http://phim3s.net/member/login/', data=data)
		try:response=response.json
		except:response={}
		utils.mess(u'%s'%response.get('message',['Login to phim3s.net fail !',''])[0],'Login to Phim3s.net')
예제 #28
0
	def login(self,username,password):
		data={'username':username,'password':password,'login':'******'}
		response=self.fetch('http://chiasenhac.com/login.php', data=data)
		if not response or response.status!=302:utils.mess(u'Login Không thành công!','chiasenhac.com')
예제 #29
0
def main():
    #try:
    s = socket.socket()
    s.connect((config.HOST, config.PORT))
    s.send("PASS {}\r\n".format(config.PASS).encode("utf-8"))
    s.send("NICK {}\r\n".format(config.NICK).encode("utf-8"))
    s.send("JOIN #{}\r\n".format(config.CHAN).encode("utf-8"))
    s.send("CAP REQ :twitch.tv/tags\r\n".encode("utf-8"))

    chat_message = re.compile(
        r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :0")
    whisper = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv WHISPER #\w+ :0")
    thread.start_new_thread(utils.fillOplist, ())
    thread.start_new_thread(utils.moneyplus, ())
    thread.start_new_thread(utils.cm_list, (s, ))
    #thread.start_new_thread(utils.donate, (s,))
    #thread.start_new_thread(utils.roulette_msg, (s,))
    while True:
        response = s.recv(1024).decode("utf-8")

        if response == "PING :tmi.twitch.tv\r\n":
            s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8"))
        else:

            try:
                server_message = chat_message.sub("", response)
            except:
                server_message = whisper.sub("", response)
                print(whisper)
            # print(response)
            try:
                message2 = server_message.split(" :", 1)
                message = message2[1]
            except:
                message = server_message
            print(message)

            username = re.search(r"\w+", message).group(0)
            if message.endswith("PRIVMSG #{} :!time\r\n".format(
                    config.CHAN)) == 1 or message.endswith(
                        "PRIVMSG #{} :!время\r\n".decode("utf-8").format(
                            config.CHAN)) == 1 or message.endswith(
                                "PRIVMSG #{} :!uptime\r\n".format(
                                    config.CHAN)) == 1:
                print(1)
                utils.stime(s)
            if message.endswith("PRIVMSG #{} :!message\r\n".format(
                    config.CHAN)) == 1:
                print(2)
                utils.mess(
                    s,
                    "Если вам понравилось, подписывайтесь на youtube https://www.youtube.com/user/Neffedyourbrain и ВК https://vk.com/sashaneff"
                    .format(username))
            if message.startswith(
                    "{}!{}@{}.tmi.twitch.tv PRIVMSG #{} :!boxAdd ".format(
                        username, username, username, config.CHAN)
            ) == 1:  # and (message2[0].find("subscriber=1") or utils.isOp(username)):
                print(3)
                box = open("box.txt", "a")
                message = message.replace(
                    "{}!{}@{}.tmi.twitch.tv PRIVMSG #{} :!boxAdd ".format(
                        username, username, username, config.CHAN), "")
                write = message.strip()
                box.write("\n" + write.encode("utf-8"))
                box.close()
                utils.mess(s, "Коробка пополнена!")
            if message.endswith(
                    "PRIVMSG #{} :!цитата\r\n".decode("utf-8").format(
                        config.CHAN)) == 1:
                print(4)
                with open("box.txt") as box:
                    array = [line.strip() for line in box]
                r = randint(0, len(array) - 1)
                utils.mess(s, array[r])
            if message.endswith(
                    "PRIVMSG #{} :!команды\r\n".decode("utf-8").format(
                        config.CHAN)) == 1:
                print(5)
                utils.mess(s, "Список команд: {}".format(utils.commands))
            if message.endswith(
                    "PRIVMSG #{} :!шерстинки\r\n".decode("utf-8").format(
                        config.CHAN)) == 1:
                print(6)
                conn = sqlite3.connect("money.sqlite")
                cursor = conn.cursor()
                cursor.execute(
                    "select money from money where name='{}'".format(username))
                result = cursor.fetchone()
                try:
                    utils.mess(
                        s, "/w {} У тебя {} {}!".format(
                            username, result[0], utils.end[result[0] % 10]))
                except:
                    utils.mess(
                        s, "/w {} Прости, что-то опять сломалось BibleThump".
                        format(username))
                conn.close()
            if message.startswith(
                    "[email protected] PRIVMSG #{} :!награда "
                    .decode("utf-8").format(config.CHAN)) == 1:
                print(7)
                conn = sqlite3.connect("money.sqlite")
                cursor = conn.cursor()
                winner = message.encode('utf-8').replace(
                    "{}!{}@{}.tmi.twitch.tv PRIVMSG #{} :!награда ".format(
                        "ncux1699", "ncux1699", "ncux1699", config.CHAN), "")
                cursor.execute(
                    "select money from money where name='{}'".format(
                        winner.strip()))
                f = cursor.fetchone()
                print(f[0])
                f1 = f[0] + 100
                cursor.execute(
                    "update money set money={} where name='{}'".format(
                        f1, winner.strip()))
                conn.commit()
                cursor.execute(
                    "select money from money where name='{}'".format(
                        winner.strip()))
                f = cursor.fetchone()
                print(f[0])
                conn.close()
                utils.mess(s, "@{} выиграл 100 шерстинок!".format(winner))
            if message.endswith(
                    "PRIVMSG #{} :!рулетка\r\n".decode("utf-8").format(
                        config.CHAN)) == 1:
                try:
                    print(8)
                    a = randint(1, 20)
                    b = randint(1, 20)
                    conn = sqlite3.connect("money.sqlite")
                    cursor = conn.cursor()
                    cursor.execute(
                        "select timer from money where name='{}'".format(
                            username))
                    f = cursor.fetchone()
                    if f[0] == 0:
                        cursor.execute(
                            "select money from money where name='{}'".format(
                                username))
                        f = cursor.fetchone()
                        if f[0] > 0:
                            cursor.execute(
                                "select score from games where game='roulette'"
                            )
                            f = cursor.fetchone()
                            if a == b:
                                cursor.execute(
                                    "update games set score=20 where game='roulette'"
                                )
                                cursor.execute(
                                    "select money from money where name='{}'".
                                    format(username))
                                fp = cursor.fetchone()
                                cursor.execute(
                                    "update money set money={} where name='{}'"
                                    .format(fp[0] + f[0], username))
                                conn.commit()
                                conn.close()
                                utils.mess(
                                    s, "@{}, поздравляю! Ты выиграл {} {}!".
                                    format(username, f[0],
                                           utils.end[f[0] % 10]))
                                utils.mess(s, "Призовой фонд сброшен до 20!")
                            else:
                                cursor.execute(
                                    "update games set score={} where game='roulette'"
                                    .format(f[0] + 5))
                                cursor.execute(
                                    "select money from money where name='{}'".
                                    format(username))
                                fp = cursor.fetchone()
                                cursor.execute(
                                    "update money set money={} where name='{}'"
                                    .format(fp[0] - 5, username))
                                cursor.execute(
                                    "update money set timer=1 where name='{}'".
                                    format(username))
                                conn.commit()
                                conn.close()
                                utils.mess(
                                    s,
                                    "/w {} не огорчайся, в следующий раз повезет. Призовой фонд увеличился и теперь составляет {} {}!"
                                    .format(username, f[0] + 5,
                                            utils.end[(f[0] + 5) % 10]))
                                #utils.mess(s, "Призовой фонд увеличился и теперь составляет {} {}!".format(f[0] + 5, utils.end[(f[0] + 5) % 10]))
                        else:
                            utils.mess(
                                s,
                                "/w {} у тебя недостаточно шерстинок, приходи на стримы чаще, не огорчай Джинджер!"
                                .format(username))
                            cursor.execute(
                                "update money set timer=1 where name='{}'".
                                format(username))
                            conn.close()
                    else:
                        utils.mess(
                            s,
                            "/w @{} не спамь, пробовать свою удачу можно только раз в минуту!"
                            .format(username))
                except:
                    utils.mess(
                        s,
                        "/w {} прости, что-то пошло не так, попробуй позже BibleThump"
                        .format(username))
            if message.endswith("PRIVMSG #{} :!топ\r\n".decode("utf-8").format(
                    config.CHAN)) == 1:
                print(9)
                conn = sqlite3.connect("money.sqlite")
                cursor = conn.cursor()
                cursor.execute(
                    "select money from money order by money desc limit 10 offset 2"
                )
                f = []
                for i in range(10):
                    c = cursor.fetchone()
                    f.append(c[0])
                cursor.execute(
                    "select name from money order by money desc limit 10 offset 2"
                )
                name = []
                for i in range(10):
                    c = cursor.fetchone()
                    name.append(c[0])
                utils.mess(
                    s,
                    "Топ 10 хранителей шерстинок: 1 - {} ({}), 2 - {} ({}), 3 - {} ({}), 4 - {} ({}), 5 - {} ({}), 6 - {} ({}), 7 - {} ({}), 8 - {} ({}), 9 - {} ({}), 10 - {} ({}),"
                    .format(name[0], f[0], name[1], f[1], name[2], f[2],
                            name[3], f[3], name[4], f[4], name[5], f[5],
                            name[6], f[6], name[7], f[7], name[8], f[8],
                            name[9], f[9]))
                conn.close()
            if message.endswith(
                    "[email protected] PRIVMSG #{} :!roulette\r\n"
                    .format(config.CHAN)) == 1:
                conn = sqlite3.connect("money.sqlite")
                cursor = conn.cursor()
                cursor.execute("select score from games where game='roulette'")
                f = cursor.fetchone()
                utils.mess(
                    s, "Призовой фонд составляет {} {}!".format(
                        f[0], utils.end[f[0] % 10]))
                utils.mess(
                    s,
                    "Чтобы попытать свою удачу в ловле шерстинок напиши !рулетка"
                )
                conn.close()
예제 #30
0
def startChatBot(chan):
    print('Chat bot starting')
    s = socket.socket()
    getConnection(s, chan)

    print("Bot started")
    timecount = time.time()
    thread.start_new_thread(utils.fillOpList, (chan, ))
    while True:
        if time.time() - timecount >= 25 * 60:
            utils.mess(
                s, chan, 'MEMES AND announcements =>'.upper() +
                'https://discord.gg/UnUhDNz <=')
            timecount = time.time()

        # try:
        rawResponse = s.recv(1024).decode('utf-8')
        # except ConnectionResetError:
        #    getConnection(s)
        # print('===== Start of rawResponse =====\n', rawResponse, end='===== End of rawResponse =====\n')

        if str(rawResponse)[0:19] in 'PING :tmi.twitch.tv':
            s.send("PONG :tmi.twitch.tv\r\n".encode('utf-8'))
        elif str(rawResponse).__contains__("Login unsuccessful"):
            utils.refreshToken(getUser(chan))
            s.close()
            s = socket.socket()
            getConnection(s, chan)
        else:
            try:
                username = str(rawResponse).split('!')[0][1:]
                message = str(rawResponse).split('#%s :' % chan)[-1].strip()
                print(time.strftime("%H:%M:%S") + ' "%s":' % username, sep='')
                print('"%s"' % message,
                      sep='',
                      end='\n=====================================\n')
            except Exception as x:
                print(
                    '==achtung==achtung==achtung==achtung==achtung==achtung==achtung=='
                    .upper())
                print('===== Exeption start =====')
                print(x, x.args)
                print('===== Exeption  end =====')
                print('===== Response start =====')
                print(rawResponse, end='')
                print('===== Response end =====')
                print('===== Username =====')
                print(username)
                print('===== Username =====')
                print(
                    '==achtung==achtung==achtung==achtung==achtung==achtung==achtung=='
                    .upper())

            if message == '!discord':
                utils.mess(s, chan, "=>https://discord.gg/UnUhDNz<=")
            if message.strip() == "!test" and utils.isOp(username):
                utils.mess(s, chan, "test?")
            if ('bigfollows' in message.lower()) and ('com'
                                                      in message.lower()):
                reason = 'Advertising'
                utils.ban(s, chan, username, reason)
                print('User: "******" was banned for the "%s"' %
                      (username, reason),
                      end='\n=====================================\n')

        time.sleep(1)
예제 #31
0
	def logout(self):
		if self.logged:
			response = self.fetch('https://www.fshare.vn/logout')
			if response and response.status==302:utils.mess(u'Logout thành công','Fshare.vn');self.logged=None
			else:utils.mess(u'Logout không thành công!','Fshare.vn')
예제 #32
0
	def get_token(self,url='https://www.fshare.vn/home'):
		self.hd['x-pjax']='true'
		response=self.fetch(url)
		if not response or response.status!=200:utils.mess(u'Get home page fail!','Fshare.vn');return ''
		self.token=utils.xsearch('data-token="(.+?)"',response.body)
		return self.token