Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- import random
- from time import sleep
- def splitText(string, symbol):
- text=[]
- word=""
- for i in string:
- if i == symbol:
- wordn = deleteNewLine(word)
- text.append(wordn)
- word = ""
- else:
- word+=i
- wordn = deleteNewLine(word)
- text.append(wordn)
- return text
- def splitSymbols(string):
- symbols = []
- for i in string:
- symbols.append(i)
- return symbols
- def deleteNewLine(string):
- word=""
- for i in string:
- if i != "\n":
- word+=i
- return word
- cnx = mysql.connector.connect(host='mysql.v62-000.myjino.ru',database='v62-000',unix_socket='/var/lib/mysql/mysql.sock',user='v62-000',password='qwerty')
- cursor = cnx.cursor()
- go = 0
- lastid=0
- IDLAST = 0
- while go == 0:
- quary = ("SELECT * FROM `message` ORDER BY `time` DESC LIMIT 0 , 1")
- cursor.execute(quary)
- messages = []
- first = 0
- for (ID,message,time) in cursor:
- text = str(ID)+":"+message
- messages.append(text)
- if first == 0:
- IDLAST = ID
- first = 1
- for i in messages:
- text = splitText(i,":")
- if text[2] == "/fuckyougod":
- if lastid!=text[0]:
- print("HEY")
- print(lastid)
- lastid = text[0]
- nid = 0
- if IDLAST!=30:
- nid = IDLAST+1
- else:
- nid = 1
- print(nid)
- query = ("REPLACE INTO `message` (id, message) VALUES ('"+str(nid)+"','GOD:FUCK YOU')")
- cursor.execute(query)
- cnx.commit()
- elif text[2] == "/gif":
- if lastid!=text[0]:
- print("HEY")
- print(lastid)
- lastid = text[0]
- nid = 0
- if IDLAST!=30:
- nid = IDLAST+1
- else:
- nid = 1
- print(nid)
- gifs=["http://0.media.dorkly.cvcdn.com/20/73/90d144c119251889319ebc533f7ba0bb.gif","https://media.giphy.com/media/10E0y3sVPdnGus/giphy.gif","http://1.media.dorkly.cvcdn.com/57/59/e93a657eec2d90205425e2c637e01f7f.gif","https://lh6.googleusercontent.com/-gghUt15LTsk/VQxKKVeM_7I/AAAAAAAAAZ8/asFUodR-U_8/w506-h910/GIF-Anime.gif","http://i.imgur.com/DHXa3ze.gif","https://s-media-cache-ak0.pinimg.com/originals/9e/58/98/9e589811edb61043b601d3186c7d212f.gif","http://media0.giphy.com/media/7u6Lr6c6ZIOqY/giphy.gif","https://s-media-cache-ak0.pinimg.com/originals/0a/83/77/0a8377fd7a9c9e52b32bca577cb25af6.gif","https://media.giphy.com/media/lvIBgQpJMPd7i/giphy.gif","http://media0.giphy.com/media/JG4iKdJamPHNK/giphy.gif","https://media.giphy.com/media/13LQZoCE0Nysr6/giphy.gif","https://media.giphy.com/media/xMpMPElKhAvgQ/giphy.gif","https://media.giphy.com/media/GhmvdoKizbEyc/giphy.gif"]
- num = random.randint(0, len(gifs)-1)
- query = ("REPLACE INTO `message` (id, message) VALUES ('"+str(nid)+"','<img src="'"'+gifs[num]+'"'">')")
- cursor.execute(query)
- cnx.commit()
- if text[2] == "HELLO GOD":
- if lastid!=text[0]:
- print("HEY")
- print(lastid)
- lastid = text[0]
- nid = 0
- if IDLAST!=30:
- nid = IDLAST+1
- else:
- nid = 1
- print(nid)
- query = ("REPLACE INTO `message` (id, message) VALUES ('"+str(nid)+"','GOD:HELLO, "+text[1]+". I am your father.')")
- cursor.execute(query)
- cnx.commit()
- if text[1] == "Echo":
- if lastid!=text[0]:
- print("HEY")
- print(lastid)
- lastid = text[0]
- nid = 0
- if IDLAST!=30:
- nid = IDLAST+1
- else:
- nid = 1
- print(nid)
- query = ("REPLACE INTO `message` (id, message) VALUES ('"+str(nid)+"','People:The Great Echo! We love you Echo!')")
- cursor.execute(query)
- cnx.commit()
- sleep(1)
- cursor.close()
- cnx.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement