Advertisement
Guest User

shitty code

a guest
Aug 19th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 165.50 KB | None | 0 0
  1. import telepot
  2. import random
  3. from random import shuffle
  4. import urbandict
  5. from random_words import RandomWords
  6. from collections import Counter
  7. import threading
  8. import json
  9. import subprocess
  10. import io
  11. import string
  12. import sqlite3
  13. import telegram
  14. import requests
  15. from PIL import Image, ImageFilter
  16. from PIL import ImageOps
  17. from collections import Counter
  18. import sys
  19. import re
  20. from threading import Thread
  21. import time
  22. from telepot.namedtuple import ReplyKeyboardMarkup, ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton, \
  23. KeyboardButton
  24. import PIL
  25. from PIL import Image, ImageFont, ImageDraw
  26. from PIL import ImageEnhance
  27. import datetime
  28. import os
  29. from gtts import gTTS
  30.  
  31. def handle(msg):
  32. #FILES AND DIRECTORIES
  33. if 'from' in msg:
  34. messageFromID = msg['from']['id']
  35. else:
  36. messageFromID = 'None'
  37. if 'type' in msg:
  38. messageType = msg['chat']['type']
  39. else:
  40. messageType = "None"
  41. try:
  42. messageType = msg['chat']['type']
  43. except:
  44. messagType = 'None'
  45. if messageType != 'private':
  46. isPrivateMessage = False
  47. toSend = True
  48. isGroup = True
  49. else:
  50. isPrivateMessage = True
  51. toSend = False
  52. isGroup = False
  53. if 'chat' in msg:
  54. chat_id = msg['chat']['id']
  55. else:
  56. chat_id = "None"
  57. if 'data' in msg:
  58. global warnd
  59. isInlineResponse = True
  60. messageInlineData = msg['data']
  61. print(messageInlineData)
  62. else:
  63. isInlineResponse = False
  64. messageInlineData = 'None'
  65. global warnd
  66. global promoted
  67. if 'message_id' in msg:
  68. messageID = str(msg['message_id'])
  69. else:
  70. messageID = 'None'
  71. if messageType != 'private':
  72. if not os.path.exists(str(chat_id)):
  73. os.makedirs(str(chat_id))
  74. os.makedirs(str(chat_id) + "/messages/")
  75. os.makedirs(str(chat_id) + "/rooms/")
  76. os.makedirs(str(chat_id) + "/data/")
  77. if not os.path.exists("data/"):
  78. os.makedirs("data/")
  79. if not os.path.exists("login/"):
  80. os.makedirs("login/")
  81. if os.path.isfile("data/usernames.txt") == False:
  82. open("data/usernames.txt", "w").write("admin\nspoon\n")
  83. if os.path.isfile(str(chat_id) + "/data/tts.txt") == False:
  84. open(str(chat_id) + "/data/tts.txt", "w").write("True")
  85. if os.path.isfile(str(chat_id) + "/data/imagecolor.txt") == False:
  86. open(str(chat_id) + "/data/imagecolor.txt", "w").write("black")
  87. if os.path.isfile(str(chat_id) + "/data/textcolor.txt") == False:
  88. open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
  89. if os.path.isfile(str(chat_id) + "/data/gamelimit.txt") == False:
  90. open(str(chat_id) + "/data/gamelimit.txt", "w").write("30")
  91. if os.path.isfile(str(chat_id) + "/data/greet.txt") == False:
  92. open(str(chat_id) + "/data/greet.txt", "w").write("Text")
  93. if os.path.isfile(str(chat_id) + "/data/games.txt") == False:
  94. open(str(chat_id) + "/data/games.txt", "w").write("True")
  95. if os.path.isfile(str(chat_id) + "/data/word.txt") == False:
  96. open(str(chat_id) + "/data/word.txt", "w").write("True")
  97. if os.path.isfile(str(chat_id) + "/data/admin.txt") == False:
  98. open(str(chat_id) + "/data/admin.txt", "w").write
  99. if os.path.isfile(str(chat_id) + "/data/jokes.txt") == False:
  100. open(str(chat_id) + "/data/jokes.txt", "w").write("False")
  101. if os.path.isfile(str(chat_id) + "/data/limit.txt") == False:
  102. open(str(chat_id) + "/data/limit.txt", "w").write("750")
  103. if os.path.isfile(str(chat_id) + "/data/8ball.txt") == False:
  104. open(str(chat_id) + "/data/8ball.txt", "w").write("False")
  105. if os.path.isfile(str(chat_id) + "/data/scramble.txt") == False:
  106. open(str(chat_id) + "/data/scramble.txt", "w").write('False')
  107. if os.path.isfile(str(chat_id) + "/data/roll.txt") == False:
  108. open(str(chat_id) + "/data/roll.txt", "w").write("False")
  109. if os.path.isfile(str(chat_id) + "/data/temp.txt") == False:
  110. open(str(chat_id) + "/data/temp.txt", "w")
  111. if os.path.isfile(str(chat_id) + "/data/lock.txt") == False:
  112. open(str(chat_id) + "/data/lock.txt", "w").write("False")
  113. if os.path.isfile(str(chat_id) + "/data/game.txt") == False:
  114. open(str(chat_id) + "/data/game.txt", "w").write("True")
  115. if os.path.isfile(str(chat_id) + "/data/pong.txt") == False:
  116. open(str(chat_id) + "/data/pong.txt", "w").write("False")
  117. if os.path.isfile(str(chat_id) + "/data/mm.txt") == False:
  118. open(str(chat_id) + "/data/mm.txt", "w").write("False")
  119. if os.path.isfile(str(chat_id) + "/data/games.txt") == False:
  120. open(str(chat_id) + "/data/games.txt", "w").write("False")
  121. if os.path.isfile(str(chat_id) + "/data/antibot.txt") == False:
  122. open(str(chat_id) + "/data/antibot.txt", "w").write("False")
  123. if os.path.isfile(str(chat_id) + "/data/flip.txt") == False:
  124. open(str(chat_id) + "/data/flip.txt", "w").write("False")
  125. if os.path.isfile(str(chat_id) + "/data/blacklist.txt") == False:
  126. open(str(chat_id) + "/data/blacklist.txt", "w")
  127. if os.path.isfile(str(chat_id) + "/data/blacklistusername.txt") == False:
  128. open(str(chat_id) + "/data/blacklistusername.txt", "w")
  129. if os.path.isfile(str(chat_id) + "/data/wel.txt") == False:
  130. open(str(chat_id) + "/data/wel.txt", "w").write("True")
  131. if os.path.isfile(str(chat_id) + "/data/photo.txt") == False:
  132. open(str(chat_id) + "/data/photo.txt", "w").write("True")
  133. if os.path.isfile(str(chat_id) + "/data/admin.txt") == False:
  134. open(str(chat_id) + "/data/admin.txt", "w")
  135. if os.path.isfile(str(chat_id) + "/data/remind.txt") == False:
  136. open(str(chat_id) + "/data/remind.txt", "w").write("False")
  137. if os.path.isfile(str(chat_id) + "/data/tts.txt") == False:
  138. open(str(chat_id) + "/data/tts.txt", "w").write("False")
  139. if os.path.isfile(str(chat_id) + "/wel.txt") == False:
  140. if messageType != 'private':
  141. open(str(chat_id) + "/wel.txt", "w").write("True")
  142. #DEFINE MESSAGES
  143. if os.path.isfile(str(chat_id) + "/data/photo.txt") == False:
  144. open(str(chat_id) + "/data/photo.txt", "w").write("True")
  145. if os.path.isfile(str(chat_id) + "/data/8ball.txt") == False:
  146. open(str(chat_id) + "/data/8ball.txt", "w").write("True")
  147. if 'text' in msg:
  148. if messageType != 'private':
  149. if os.path.isfile("rooms/" + str(messageFromID) + "wins.txt") == False:
  150. open("rooms/" + str(messageFromID) + "wins.txt", "w").write("0")
  151. if os.path.isfile("rooms/" + str(messageFromID) + "money.txt") == False:
  152. open("rooms/" + str(messageFromID) + "money.txt", "w").write("100")
  153. if os.path.isfile(str(chat_id) + "/messagecount.txt") == False:
  154. open(str(chat_id) + "/messagecount.txt", "w").write("1")
  155. else:
  156. minus = int(str(open(str(chat_id) + "/messagecount.txt", "r+").readlines()).replace("[", "").replace("'", "").replace("]", "")) + 1
  157. open(str(chat_id) + "/messagecount.txt", "w").write(str(minus))
  158. if os.path.isfile(
  159. str(chat_id) +
  160. "/messages/" + str(messageFromID) + ".txt") == False:
  161. open(
  162. str(chat_id) +
  163. "/messages/" + str(messageFromID) + ".txt", "w").write("1")
  164. else:
  165. minus = int(
  166. str(open(
  167. str(chat_id) +
  168. "/messages/" + str(messageFromID) + ".txt", "r+").readlines()).replace("[", "").replace(
  169. "'", "").replace("]", "")) + 1
  170. open(
  171. str(chat_id) +
  172. "/messages/" + str(messageFromID) + ".txt", "w").write(str(minus))
  173. message = msg['text'].lower()
  174. if isPrivateMessage == False:
  175. print(msg['chat']['title'], ', ', msg['from']['first_name'], ':\n', msg['text'])
  176. else:
  177. print('Private Message, ', msg['from']['first_name'], ':\n', msg['text'])
  178. else:
  179. message = 'None'
  180. if 'username' in msg['from']:
  181. username = str("@" + msg['from']['username'])
  182. else:
  183. username = msg['from']['first_name']
  184. if 'caption' in msg:
  185. caption = msg['caption']
  186. else:
  187. caption = 'None'
  188. if 'voice' in msg:
  189. voiceMessage = msg['voice']['file_id']
  190. else:
  191. voiceMessage = 'None'
  192. if 'photo' in msg:
  193. print(str(msg['from']['first_name']) + " sent a photo.")
  194. if messageType != 'private':
  195. if os.path.isfile("rooms/" + str(messageFromID) + "wins.txt") == False:
  196. open("rooms/" + str(messageFromID) + "wins.txt", "w").write("0")
  197. if os.path.isfile("rooms/" + str(messageFromID) + "money.txt") == False:
  198. open("rooms/" + str(messageFromID) + "money.txt", "w").write("100")
  199. if os.path.isfile(str(chat_id) + "/messagecount.txt") == False:
  200. open(str(chat_id) + "/messagecount.txt", "w").write("1")
  201. else:
  202. minus = int(str(open(str(chat_id) + "/messagecount.txt", "r+").readlines()).replace("[", "").replace(
  203. "'", "").replace("]", "")) + 1
  204. open(str(chat_id) + "/messagecount.txt", "w").write(str(minus))
  205. if os.path.isfile(
  206. str(chat_id) +
  207. "/messages/" + str(messageFromID) + ".txt") == False:
  208. open(
  209. str(chat_id) +
  210. "/messages/" + str(messageFromID) + ".txt", "w").write("1")
  211. else:
  212. minus = int(
  213. str(open(
  214. str(chat_id) +
  215. "/messages/" + str(messageFromID) + ".txt", "r+").readlines()).replace("[", "").replace(
  216. "'", "").replace("]", "")) + 1
  217. open(
  218. str(chat_id) +
  219. "/messages/" + str(messageFromID) + ".txt", "w").write(str(minus))
  220. photo = msg['photo']
  221. else:
  222. photo = 'None'
  223. if 'reply_to_message' in msg:
  224. messageReply = msg['reply_to_message']['from']['id']
  225. else:
  226. messageReply = 'None'
  227. if 'sticker' in msg:
  228. print(msg['from']['first_name'] + " sent a sticker.")
  229. if messageType != 'private':
  230. if os.path.isfile("rooms/" + str(messageFromID) + "wins.txt") == False:
  231. open("rooms/" + str(messageFromID) + "wins.txt", "w").write("0")
  232. if os.path.isfile("rooms/" + str(messageFromID) + "money.txt") == False:
  233. open("rooms/" + str(messageFromID) + "money.txt", "w").write("100")
  234. if os.path.isfile(str(chat_id) + "/messagecount.txt") == False:
  235. open(str(chat_id) + "/messagecount.txt", "w").write("1")
  236. else:
  237. minus = int(str(open(str(chat_id) + "/messagecount.txt", "r+").readlines()).replace("[", "").replace(
  238. "'", "").replace("]", "")) + 1
  239. open(str(chat_id) + "/messagecount.txt", "w").write(str(minus))
  240. if os.path.isfile(
  241. str(chat_id) +
  242. "/messages/" + str(messageFromID) + ".txt") == False:
  243. open(
  244. str(chat_id) +
  245. "/messages/" + str(messageFromID) + ".txt", "w").write("1")
  246. else:
  247. minus = int(
  248. str(open(
  249. str(chat_id) +
  250. "/messages/" + str(messageFromID) + ".txt", "r+").readlines()).replace("[", "").replace(
  251. "'", "").replace("]", "")) + 1
  252. open(
  253. str(chat_id) +
  254. "/messages/" + str(messageFromID) + ".txt", "w").write(str(minus))
  255. if 'data' in msg:
  256. global warnd
  257. isInlineResponse = True
  258. messageInlineData = msg['data']
  259. print(messageInlineData)
  260. else:
  261. isInlineResponse = False
  262. messageInlineData = 'None'
  263. global warnd
  264. global promoted
  265. messageFromID = messageFromID
  266. #DEFINE COMMANDS
  267. eightball = ["Not so sure", "That could be possible", "Most likely", "Absolutely not", "Outlook is good",
  268. "I see good things happening", "Never",
  269. "Negative", "Could be", "Unclear, ask again", "Yes", "No", "Possible, but not probable"]
  270. jokes = ["Why did the boy drop his ice cream? Because he was hit by a bus.", "A dyslexic man walks into a bra.",
  271. "What is green and has wheels. Grass, I lied about the wheels.",
  272. "What is red and smells like blue paint? Red paint.",
  273. "Knock knock. Who's there? Dave. Dave who? Dave began to break into tears as his Grandmother's Alzheimer's had gotten progressively worse.",
  274. "What is brown and sticky? A stick.",
  275. "A horse walked into a bar. Several people got up and left as they spotted the potential danger in the situation.",
  276. "How do you make a plumber cry? You kill his family.",
  277. "A man walks into a bar, he is an alcoholic and he is ruining his family.",
  278. "What does an Eagle and a Mole have in common? They both live underground. Apart from the Eagle.",
  279. "Why did Suzie fall off the swing? She had no arms.",
  280. "A duck walks into a bar, the bartender says 'What'll it be?' The duck doesn't say anything because it is a duck.",
  281. "A dog walks into a bar and asks for a drink. The bartender goes to get him a drink, but then realizes how ridiculous this is and wakes up from his dream. He rolls over to tell his wife about it, but she ignores him. He begins to cry silently, realizing his marriage is in shambles."]
  282.  
  283. commandsList = ['hi bot', '/gt', '/scramble', "/m8", "/toggles", "/magic8", "/pin", '/polaroid', '/color', '/colour', '/start', '/rblur', '/swirl', '/help', "/greet", "/eb", '/com', '/id', '/google', '/title', '/time', '/give', '/stick', '/chatid', '/pin', '/unban', '/ud', '/slap', '/promote', '/demote', '/unmute', 'hey bot', '/unban', '/byebot', '/rt', "/roll", '/wt', "/warn", "/wel", "/check", "/reset", "/callme", "/forget", "/imagesearch", "/ban", "/kick", "/contour", "/invert", "/saturate", "/posterize", "/equalize", "/blur", "/sharpen", "/solarize", "/caption", "/photo"]
  284.  
  285. def getpfp():
  286. try:
  287. if 'reply_to_message' in msg:
  288. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  289. profiles = bot.getUserProfilePhotos(msg['reply_to_message']['from']['id'])
  290. file_id = profiles['photos'][0][2]['file_id']
  291. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  292. bot.download_file(file_id, filename)
  293. bot.sendPhoto(messageFromID, open(filename, "rb"))
  294. os.remove(filename)
  295. else:
  296. bot.sendMessage(chat_id, "Reply to someone.")
  297. except:
  298. bot.sendMessage(chat_id, "You have to PM first in order to receive private messages.")
  299.  
  300. if "/getpfp" in message:
  301. t = threading.Thread(target=getpfp)
  302. t.start()
  303.  
  304. def caption():
  305. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  306. numbe = msg['text'][9:]
  307. size = numbe.split("::")[1]
  308. number = numbe.split("::", 1)[0]
  309. file_id = msg['reply_to_message']['photo'][2]['file_id']
  310. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  311. bot.download_file(file_id, filename)
  312. img = PIL.Image.open(filename)
  313. draw = PIL.ImageDraw.Draw(img)
  314. w, h = img.size
  315. font = ImageFont.truetype("comic.ttf", int(size))
  316. text_w, text_h = draw.textsize(number, font)
  317. draw.text(((w - text_w) // 2, h - text_h), number, (255, 255, 255), font=font)
  318. img.save("1" + filename)
  319. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  320. os.remove(filename)
  321. os.remove("1" + filename)
  322. def rblur():
  323. if chat_id == -1001088621659:
  324. ()
  325. else:
  326. file_id = msg['reply_to_message']['photo'][2]['file_id']
  327. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  328. bot.download_file(file_id, filename)
  329. bashCommand = "convert " + str(msg['reply_to_message']['from']['id']) + ".jpg" + " -radial-blur 10 " + str(
  330. msg['reply_to_message']['from']['id']) + ".jpg"
  331. subprocess.check_output(['bash', '-c', bashCommand])
  332. bot.sendPhoto(chat_id, open(str(msg['reply_to_message']['from']['id']) + ".jpg", "rb"))
  333. os.remove(filename)
  334. def swirl():
  335. if chat_id == -1001088621659:
  336. ()
  337. else:
  338. file_id = msg['reply_to_message']['photo'][2]['file_id']
  339. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  340. bot.download_file(file_id, filename)
  341. bashCommand = "convert " + str(msg['reply_to_message']['from']['id']) + ".jpg" + " -swirl 180 " + str(
  342. msg['reply_to_message']['from']['id']) + ".jpg"
  343. subprocess.check_output(['bash', '-c', bashCommand])
  344. bot.sendPhoto(chat_id, open(str(msg['reply_to_message']['from']['id']) + ".jpg", "rb"))
  345. os.remove(filename)
  346. def polar():
  347. text = msg['text'][10:]
  348. file_id = msg['reply_to_message']['photo'][2]['file_id']
  349. filename = str(msg['reply_to_message']['from']['id']) + ".png"
  350. bot.download_file(file_id, filename)
  351. bashCommand = "convert -caption '" + str(text) + "' \
  352. " + filename + " -thumbnail 480x480 \
  353. -bordercolor Lavender -border 5x5 -density 144 \
  354. -gravity center -pointsize 20 -background black \
  355. -polaroid -15 -resize 50% " + filename
  356. subprocess.check_output(['bash', '-c', bashCommand])
  357. bot.sendPhoto(chat_id, open(filename, "rb"))
  358. os.remove(filename)
  359. if "/polaroid" in message:
  360. if "True" in open(str(chat_id) + "/data/photo.txt"):
  361. t = threading.Thread(target=polar)
  362. t.start()
  363. if "/swirl" in message:
  364. if "True" in open(str(chat_id) + "/data/photo.txt"):
  365. t = threading.Thread(target=swirl)
  366. t.start()
  367.  
  368. def saturatee():
  369. if "True" in open(str(chat_id) + "/data/photo.txt"):
  370. if 'reply_to_message' in msg:
  371. try:
  372. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  373. number = message[10:]
  374. file_id = msg['reply_to_message']['photo'][2]['file_id']
  375. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  376. bot.download_file(file_id, filename)
  377. img = PIL.Image.open(filename)
  378. convert = PIL.ImageEnhance.Color(img)
  379. img2 = convert.enhance(int(number))
  380. img2.save("1" + filename)
  381. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  382. os.remove(filename)
  383. os.remove("1" + filename)
  384. except:
  385. ()
  386. else:
  387. bot.sendMessage(chat_id, "Reply to a photo.")
  388. def contour():
  389. if "True" in open(str(chat_id) + "/data/photo.txt"):
  390. if 'reply_to_message' in msg:
  391. try:
  392. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  393. number = message[10:]
  394. file_id = msg['reply_to_message']['photo'][2]['file_id']
  395. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  396. bot.download_file(file_id, filename)
  397. im = filename
  398. img = PIL.Image.open(im)
  399. im1 = img.filter(ImageFilter.CONTOUR)
  400. im1.save("1" + filename)
  401. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  402. os.remove(filename)
  403. os.remove("1" + filename)
  404. except:
  405. ()
  406. else:
  407. bot.sendMessage(chat_id, "Reply to a photo.")
  408. def blur():
  409. if "True" in open(str(chat_id) + "/data/photo.txt"):
  410. if 'reply_to_message' in msg:
  411. try:
  412. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  413. number = message[5:]
  414. file_id = msg['reply_to_message']['photo'][2]['file_id']
  415. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  416. bot.download_file(file_id, filename)
  417. im = filename
  418. img = PIL.Image.open(im)
  419. im1 = img.filter(ImageFilter.GaussianBlur(radius=int(number)))
  420. im1.save("1" + filename)
  421. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  422. os.remove(filename)
  423. os.remove("1" + filename)
  424. except:
  425. ()
  426. else:
  427. bot.sendMessage(chat_id, "Reply to a photo.")
  428. def sharpen():
  429. if 'reply_to_message' in msg:
  430. try:
  431. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  432. file_id = msg['reply_to_message']['photo'][2]['file_id']
  433. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  434. bot.download_file(file_id, filename)
  435. im = filename
  436. img = PIL.Image.open(im)
  437. im1 = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
  438. im1.save("1" + filename)
  439. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  440. os.remove(filename)
  441. os.remove("1" + filename)
  442. except:
  443. ()
  444. def solarize():
  445. if "True" in open(str(chat_id) + "/data/photo.txt"):
  446. if 'reply_to_message' in msg:
  447. try:
  448. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  449. number = message[10:]
  450. file_id = msg['reply_to_message']['photo'][2]['file_id']
  451. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  452. bot.download_file(file_id, filename)
  453. img = PIL.Image.open(filename)
  454. convert = PIL.ImageOps.solarize(img, threshold=128)
  455. convert.save("1" + filename)
  456. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  457. os.remove(filename)
  458. os.remove("1" + filename)
  459. except:
  460. ()
  461. else:
  462. bot.sendMessage(chat_id, "Reply to a photo.")
  463.  
  464. if "/solarize" in message:
  465. t = threading.Thread(target=solarize)
  466. t.start()
  467.  
  468. def equalize():
  469. if "True" in open(str(chat_id) + "/data/photo.txt"):
  470. if 'reply_to_message' in msg:
  471. try:
  472. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  473. number = message[10:]
  474. file_id = msg['reply_to_message']['photo'][2]['file_id']
  475. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  476. bot.download_file(file_id, filename)
  477. img = PIL.Image.open(filename)
  478. convert = PIL.ImageOps.equalize(img)
  479. convert.save("1" + filename)
  480. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  481. os.remove(filename)
  482. os.remove("1" + filename)
  483. except:
  484. ()
  485. else:
  486. bot.sendMessage(chat_id, "Reply to a photo.")
  487.  
  488. if "/equalize" in message:
  489. t = threading.Thread(target=solarize)
  490. t.start()
  491.  
  492. def posterize():
  493. if "True" in open(str(chat_id) + "/data/photo.txt"):
  494. if 'reply_to_message' in msg:
  495. try:
  496. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  497. number = message[10:]
  498. file_id = msg['reply_to_message']['photo'][2]['file_id']
  499. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  500. bot.download_file(file_id, filename)
  501. img = PIL.Image.open(filename)
  502. convert = PIL.ImageOps.posterize(img, 2)
  503. convert.save("1" + filename)
  504. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  505. os.remove(filename)
  506. os.remove("1" + filename)
  507. except:
  508. ()
  509. else:
  510. bot.sendMessage(chat_id, "Reply to a photo.")
  511.  
  512. if "/posterize" in message:
  513. t = threading.Thread(target=posterize)
  514. t.start()
  515.  
  516. def invert():
  517. if "True" in open(str(chat_id) + "/data/photo.txt"):
  518. if 'reply_to_message' in msg:
  519. try:
  520. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  521. number = message[10:]
  522. file_id = msg['reply_to_message']['photo'][2]['file_id']
  523. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  524. bot.download_file(file_id, filename)
  525. img = PIL.Image.open(filename)
  526. convert = PIL.ImageOps.invert(img)
  527. convert.save("1" + filename)
  528. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  529. os.remove(filename)
  530. os.remove("1" + filename)
  531. except:
  532. ()
  533. else:
  534. bot.sendMessage(chat_id, "Reply to a photo.")
  535.  
  536. if "/invert" in message:
  537. t = threading.Thread(target=invert)
  538. t.start()
  539.  
  540. def saturate():
  541. try:
  542. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  543. file_id = msg['reply_to_message']['photo'][2]['file_id']
  544. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  545. bot.download_file(file_id, filename)
  546. img = PIL.Image.open(filename)
  547. convert = PIL.ImageEnhance.Color(img)
  548. img2 = convert.enhance(10)
  549. img2.save("1" + filename)
  550. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  551. os.remove(filename)
  552. os.remove("1" + filename)
  553. except:
  554. bot.sendMessage(chat_id, "/saturate <Amount of saturation in numbers>")
  555.  
  556. def captionb():
  557. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  558. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  559. if 'reply_to_message' in msg:
  560. try:
  561. numbe = msg['text'][10:]
  562. size = numbe.split("::")[1]
  563. number = numbe.split("::", 1)[0]
  564. file_id = msg['reply_to_message']['photo'][2]['file_id']
  565. filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
  566. bot.download_file(file_id, filename)
  567. img = PIL.Image.open(filename)
  568. draw = PIL.ImageDraw.Draw(img)
  569. w, h = img.size
  570. font = ImageFont.truetype("comic.ttf", int(size))
  571. text_w, text_h = draw.textsize(number, font)
  572. draw.text(((w - text_w) // 2, h - text_h), number, (0, 0, 0), font=font)
  573. img.save("1" + filename)
  574. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  575. os.remove(filename)
  576. os.remove("1" + filename)
  577. except:
  578. ()
  579. else:
  580. bot.sendMessage(chat_id, "Reply to a photo.")
  581.  
  582. def captionerror():
  583. bot.sendMessage(chat_id, "/caption text::textsize (in numbers)")
  584.  
  585. def captionerrorb():
  586. bot.sendMessage(chat_id, "/captionb text::textsize (in numbers)")
  587. if message == "/caption":
  588. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  589. t = threading.Thread(target=captionerror)
  590. t.start()
  591. if "/caption " in message:
  592. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  593. if 'reply_to_message' in msg:
  594. t = threading.Thread(target=caption)
  595. t.start()
  596. else:
  597. bot.sendMessage(chat_id, "Please reply to a photo.")
  598. if "/rblur" in message:
  599. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  600. if 'reply_to_message' in msg:
  601. t = threading.Thread(target=rblur)
  602. t.start()
  603. else:
  604. bot.sendMessage(chat_id, "Please reply to a photo.")
  605. if message == "/captionb":
  606. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  607. t = threading.Thread(target=captionerrorb)
  608. t.start()
  609. if message.startswith("/captionb "):
  610. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  611. if 'reply_to_message' in msg:
  612. t = threading.Thread(target=captionb)
  613. t.start()
  614. else:
  615. bot.sendMessage(chat_id, "Please reply to a photo.")
  616. if message == "/saturate":
  617. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  618. if 'reply_to_message' in msg:
  619. t = threading.Thread(target=saturate)
  620. t.start()
  621. else:
  622. bot.sendMessage(chat_id, "Please respond to a photo.")
  623. if "/contour" in message:
  624. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  625. if 'reply_to_message' in msg:
  626. t = threading.Thread(target=contour)
  627. t.start()
  628. else:
  629. bot.sendMessage(chat_id, "Please respond to a photo.")
  630. if "/blur " in message:
  631. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  632. if 'reply_to_message' in msg:
  633. t = threading.Thread(target=blur)
  634. t.start()
  635. else:
  636. bot.sendMessage(chat_id, "Please respond to a photo.")
  637. if "/sharpen" in message:
  638. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  639. if 'reply_to_message' in msg:
  640. t = threading.Thread(target=sharpen)
  641. t.start()
  642. else:
  643. bot.sendMessage(chat_id, "Please respond to a photo.")
  644. if message.startswith("/saturate "):
  645. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  646. if 'reply_to_message' in msg:
  647. t = threading.Thread(target=saturatee)
  648. t.start()
  649. else:
  650. bot.sendMessage(chat_id, "Please respond to a photo.")
  651. def imagesearch():
  652. if 'reply_to_message' in msg:
  653. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  654. file_id = msg['reply_to_message']['photo'][2]['file_id']
  655. filename = str(msg['reply_to_message']['from']['id']) + str(random.randint(1, 100000)) + ".jpg"
  656. bot.download_file(file_id, "/home6/dylanisa/public_html/" + filename)
  657. google = str("https://www.google.com/searchbyimage?&image_url=dylanisaturtle.com/" + filename)
  658. bot.sendMessage(chat_id, "[Image Searched!]" + "(" + google + ")",
  659. reply_to_message_id=msg['message_id'],
  660. parse_mode="markdown", disable_web_page_preview=True)
  661. os.remove(filename)
  662. else:
  663. bot.sendMessage(chat_id, "Reply to a photo.")
  664.  
  665. def toggle():
  666. if "True" in open(str(chat_id) + "/data/jokes.txt", "r"):
  667. Jks = "*On*"
  668. if "False" in open(str(chat_id) + "/data/jokes.txt", "r"):
  669. Jks = "*Off*"
  670. if "True" in open(str(chat_id) + "/data/8ball.txt", "r"):
  671. eB = "*On*"
  672. if "False" in open(str(chat_id) + "/data/8ball.txt", "r"):
  673. eB = "*Off*"
  674. if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
  675. rL = "*On*"
  676. if "False" in open(str(chat_id) + "/data/roll.txt", "r"):
  677. rL = "*Off*"
  678. if "True" in open(str(chat_id) + "/data/lock.txt", "r"):
  679. gL = "*On*"
  680. if "False" in open(str(chat_id) + "/data/lock.txt", "r"):
  681. gL = "*Off*"
  682. if "True" in open(str(chat_id) + "/data/pong.txt", "r"):
  683. pL = "*On*"
  684. if "False" in open(str(chat_id) + "/data/pong.txt", "r"):
  685. pL = "*Off*"
  686. if "True" in open(str(chat_id) + "/data/mm.txt", "r"):
  687. mL = "*On*"
  688. if "False" in open(str(chat_id) + "/data/mm.txt", "r"):
  689. mL = "*Off*"
  690. if "True" in open(str(chat_id) + "/data/antibot.txt", "r"):
  691. aB = "*On*"
  692. if "False" in open(str(chat_id) + "/data/antibot.txt", "r"):
  693. aB = "*Off*"
  694. if "True" in open(str(chat_id) + "/data/flip.txt", "r"):
  695. fL = "*On*"
  696. if "False" in open(str(chat_id) + "/data/flip.txt", "r"):
  697. fL = "*Off*"
  698. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  699. pT = "*On*"
  700. if "False" in open(str(chat_id) + "/data/photo.txt", "r"):
  701. pT = "*Off*"
  702. bot.sendMessage(chat_id,
  703. "Jokes: " + Jks + "\nMagic 8Ball: " + eB + "\nRolling: " + rL + "\nGroup Lock: " + gL + "\nPing/Pong: " + pL + "\nMake me: " + mL + "\nAntibot: " + aB + "\nFlip: " + fL + "\nPhoto edit: " + pT, parse_mode='markdown')
  704. def roll2():
  705. edited = telepot.message_identifier(bot.sendMessage(chat_id, 'Rolling two dice...'))
  706. time.sleep(0.7)
  707. rollrandom = str(random.randint(1, 6))
  708. rollrandom2 = str(random.randint(1, 6))
  709. bot.editMessageText(edited, "*" + str(rollrandom) + "* and a", parse_mode="markdown")
  710. time.sleep(0.5)
  711. bot.editMessageText(edited, "*" + str(rollrandom) + "*" + " and a " + "*" + str(rollrandom2) + "*",
  712. parse_mode="markdown")
  713.  
  714. def roll1():
  715. edited = telepot.message_identifier(bot.sendMessage(chat_id, 'Rolling a single dice'))
  716. time.sleep(0.7)
  717. bot.editMessageText(edited, "*" + str(random.randint(1, 6)) + "*", parse_mode="markdown")
  718.  
  719. if message == "/roll":
  720. if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
  721. t = threading.Thread(target=roll1)
  722. t.start()
  723. if "/roll2" in message:
  724. if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
  725. t = threading.Thread(target=roll2)
  726. t.start()
  727. if "/id" in message:
  728. try:
  729. bot.sendMessage(chat_id, msg['reply_to_message']['from']['id'])
  730. except:
  731. bot.sendMessage(chat_id, messageFromID)
  732. if "/chatid" in message:
  733. bot.sendMessage(chat_id, chat_id)
  734. if "/com" in message:
  735. bot.sendMessage(chat_id, "Commands:\n/roll and /roll2\n/saturate\n/solarize\n/posterize\n/swirl\n/polaroid\n/rblur\n/caption and /captionb for black text\n/kickme\n/def\n/jokes\n/callme\n/blur\n/contour\n/check\n/equalize\n/sharpen\n/invert\n/equalize\n/imagesearch")
  736. if message == "/kickme":
  737. try:
  738. bot.kickChatMember(chat_id, messageFromID)
  739. bot.unbanChatMember(chat_id, messageFromID)
  740. except:
  741. bot.sendMessage(chat_id, "Oops! Either you're admin, or I am not admin.")
  742. if os.path.isfile(str(chat_id) + "/data/c" + str(message).replace("/", "slas12") + ".txt") == True:
  743. bot.sendMessage(chat_id, str(open(str(chat_id) + "/data/c" + str(message).replace("/", "slas12") + ".txt", "r").read()))
  744. else:
  745. f = ""
  746. lines = ""
  747. def admincom():
  748. if "/color" in message:
  749. if "green" in message:
  750. open(str(chat_id) + "/data/imagecolor.txt", "w").write("green")
  751. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  752. bot.sendMessage(chat_id, "Color set to green.")
  753. elif "red" in message:
  754. open(str(chat_id) + "/data/imagecolor.txt", "w").write("red")
  755. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  756. bot.sendMessage(chat_id, "Color set to red.")
  757. elif "blue" in message:
  758. open(str(chat_id) + "/data/imagecolor.txt", "w").write("blue")
  759. open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
  760. bot.sendMessage(chat_id, "Color set to blue.")
  761. elif "black" in message:
  762. open(str(chat_id) + "/data/imagecolor.txt", "w").write("black")
  763. open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
  764. bot.sendMessage(chat_id, "Color set to black.")
  765. elif "white" in message:
  766. open(str(chat_id) + "/data/imagecolor.txt", "w").write("white")
  767. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  768. bot.sendMessage(chat_id, "Color set to white.")
  769. elif "orange" in message:
  770. open(str(chat_id) + "/data/imagecolor.txt", "w").write("orange")
  771. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  772. bot.sendMessage(chat_id, "Color set to orange.")
  773. elif "yellow" in message:
  774. open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
  775. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  776. bot.sendMessage(chat_id, "Color set to yellow.")
  777. elif "gold" in message:
  778. open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
  779. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  780. bot.sendMessage(chat_id, "Color set to gold.")
  781. elif "pink" in message:
  782. open(str(chat_id) + "/data/imagecolor.txt", "w").write("pink")
  783. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  784. bot.sendMessage(chat_id, "Color set to pink.")
  785. elif "purple" in message:
  786. open(str(chat_id) + "/data/imagecolor.txt", "w").write("purple")
  787. open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
  788. bot.sendMessage(chat_id, "Color set to purple.")
  789. if "/colour" in message:
  790. if "green" in message:
  791. open(str(chat_id) + "/data/imagecolor.txt", "w").write("green")
  792. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  793. bot.sendMessage(chat_id, "Colour set to green.")
  794. elif "red" in message:
  795. open(str(chat_id) + "/data/imagecolor.txt", "w").write("red")
  796. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  797. bot.sendMessage(chat_id, "Colour set to red.")
  798. elif "blue" in message:
  799. open(str(chat_id) + "/data/imagecolor.txt", "w").write("blue")
  800. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  801. bot.sendMessage(chat_id, "Colour set to blue.")
  802. elif "black" in message:
  803. open(str(chat_id) + "/data/imagecolor.txt", "w").write("black")
  804. open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
  805. bot.sendMessage(chat_id, "Colour set to black.")
  806. elif "white" in message:
  807. open(str(chat_id) + "/data/imagecolor.txt", "w").write("white")
  808. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  809. bot.sendMessage(chat_id, "Colour set to white.")
  810. elif "orange" in message:
  811. open(str(chat_id) + "/data/imagecolor.txt", "w").write("orange")
  812. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  813. bot.sendMessage(chat_id, "Colour set to orange.")
  814. elif "yellow" in message:
  815. open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
  816. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  817. bot.sendMessage(chat_id, "Colour set to yellow.")
  818. elif "gold" in message:
  819. open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
  820. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  821. bot.sendMessage(chat_id, "Colour set to gold.")
  822. elif "pink" in message:
  823. open(str(chat_id) + "/data/imagecolor.txt", "w").write("pink")
  824. open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
  825. bot.sendMessage(chat_id, "Colour set to pink.")
  826. elif "purple" in message:
  827. open(str(chat_id) + "/data/imagecolor.txt", "w").write("purple")
  828. open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
  829. bot.sendMessage(chat_id, "Colour set to purple.")
  830. if "/addcom " in message:
  831. if os.path.isfile(str(chat_id) + "/data/c" + str(message[8:]) + ".txt") == False:
  832. if "/" in message[8:]:
  833. command = message[8:].replace("/", "slas12")
  834. else:
  835. command = message[8:]
  836. open(str(chat_id) + "/data/c" + str(command).split("::")[0] + ".txt", "w").write("")
  837. open(str(chat_id) + "/data/commandlist.txt", "a").write(str(command) + "\n")
  838. open(str(chat_id) + "/data/c" + str(command).split("::")[0] + ".txt", "w").write(str(message[8:]).split("::")[1])
  839. bot.sendMessage(chat_id, "Command added.")
  840. else:
  841. bot.sendMessage(chat_id, "This command is already added.")
  842. if "/delcom " in message:
  843. if os.path.isfile(str(chat_id) + "/data/c" + str(message[8:]).replace("/", "slas12") + ".txt") == True:
  844. os.remove(str(chat_id) + "/data/c" + str(message[8:]).replace("/", "slas12") + ".txt")
  845. with open(str(chat_id) + "/data/commandlist.txt", "r+") as f:
  846. t = f.read()
  847. f.seek(0)
  848. for line in t.split('\n'):
  849. if line != str(str(message[8:]).replace("/", "slas12").lower()):
  850. f.write(line + '\n')
  851. f.truncate()
  852. bot.sendMessage(chat_id, "Command deleted.")
  853. else:
  854. bot.sendMessage(chat_id, "This command is not added.")
  855. if "/time " in message:
  856. if re.search('[a-zA-Z]', message[6:]):
  857. bot.sendMessage(chat_id, "The time limit can not be a letter.")
  858. else:
  859. open(str(chat_id) + "/data/gamelimit.txt", "w").write(message[6:])
  860. bot.sendMessage(chat_id, "Game time limit set to " + message[6:] + " second(s)")
  861. if "/admincom" in message:
  862. bot.sendMessage(chat_id, "Admin Commands:\n/greet (change greet type)\n/time (for games)\n/promote and /demote\n/ban and /unban\n/kick\n/addcom and /delcom (add custom commands)\n/mute and /unmute\n/byebot (Makes the bot leave the group)\n/photo\n/wel (Toggles welcome message)\n/eb (Toggles 8ball)\n/jt (Toggles jokes)\n/rt (Toggles rolling)\n/gt (Toggles games)\n/reset (Removes warns)\n/end (Ends current game)\n/toggles (Shows whats on and off, some are fillers)\n/time (Set's game time limit)")
  863. if "/end" in message:
  864. bot.sendMessage(chat_id, str(msg['from']['first_name']) + " reset the game. The word was " + open(
  865. str(chat_id) + "/data/word.txt", "r").read())
  866. open(str(chat_id) + "/data/scramble.txt", "w").write("False")
  867. def dell():
  868. print(messageID)
  869. if 'reply_to_message' in msg:
  870. telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id,
  871. message_id=msg['reply_to_message']['message_id'])
  872. telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
  873. else:
  874. telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
  875. if message.startswith("/del"):
  876. if message.startswith("/delcom"):
  877. ()
  878. else:
  879. t = threading.Thread(target=dell)
  880. t.start()
  881. if bot.getChatMember(chat_id, messageFromID) in bot.getChatAdministrators(chat_id):
  882. if "/promote" in message:
  883. if msg['reply_to_message']['from']['id'] == 353129131:
  884. bot.sendMessage(chat_id, "Uhh I don't need to be admin of myself lol")
  885. else:
  886. if bot.getChatMember(chat_id,
  887. msg['reply_to_message']['from']['id']) in bot.getChatAdministrators(
  888. chat_id):
  889. bot.sendMessage(chat_id,
  890. "You're admin of the group, you already have access to my commands.")
  891. else:
  892. if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt").read():
  893. bot.sendMessage(chat_id, "This user is already an admin. To demote, type /demote")
  894. else:
  895. open(str(chat_id) + "/data/admin.txt", "a").write(str(msg['reply_to_message']['from']['id']) + "\n")
  896. bot.sendMessage(chat_id, str(msg['reply_to_message']['from']['first_name']) + " has been promoted")
  897. if "/demote" in message:
  898. print(str(chat_id) + '/data/admin.txt')
  899. if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt").read():
  900. with open(str(chat_id) + "/data/admin.txt", "r+") as f:
  901. t = f.read()
  902. f.seek(0)
  903. for line in t.split('\n'):
  904. if line != str(msg['reply_to_message']['from']['id']):
  905. f.write(line + '\n')
  906. f.truncate()
  907. bot.sendMessage(chat_id, "This user has been demoted.")
  908. else:
  909. bot.sendMessage(chat_id, "This user isn't promoted.")
  910. if "/ban" in message:
  911. if bot.getChatMember(chat_id, 353129131) in bot.getChatAdministrators(chat_id):
  912. if bot.getChatMember(chat_id,
  913. msg['reply_to_message']['from']['id']) in bot.getChatAdministrators(
  914. chat_id):
  915. bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
  916. else:
  917. bot.sendMessage(chat_id, msg['reply_to_message']['from']['first_name'] + " has been banned by " +
  918. msg['from']['first_name'] + ".")
  919. open(str(chat_id) + "/data/unban.txt", "w").write(
  920. str(msg['reply_to_message']['from']['id']))
  921. global banned
  922. bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
  923. else:
  924. bot.sendMessage(chat_id, "Error: I need to be admin.")
  925. if "/mute" in message:
  926. bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=False,
  927. can_add_web_page_previews=False, can_send_media_messages=False,
  928. can_send_other_messages=False)
  929. bot.sendMessage(chat_id, "This user has been muted.")
  930. if "/unmute" in message:
  931. bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=True,
  932. can_add_web_page_previews=True, can_send_media_messages=True,
  933. can_send_other_messages=True)
  934. bot.sendMessage(chat_id, "This user has been unmuted.")
  935. if "/unban" in message:
  936. if bot.getChatMember(chat_id, 353129131) in bot.getChatAdministrators(chat_id):
  937. if bot.getChatMember(chat_id,
  938. msg['reply_to_message']['from']['id']) in bot.getChatAdministrators(
  939. chat_id):
  940. bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
  941. else:
  942. bot.sendMessage(chat_id, "User has been unbanned")
  943. open(str(chat_id) + "/data/unban.txt", "w").write(
  944. str(msg['reply_to_message']['from']['id']))
  945. global banned
  946. bot.unbanChatMember(chat_id, msg['reply_to_message']['from']['id'])
  947. else:
  948. bot.sendMessage(chat_id, "Error: I need to be admin.")
  949. if "/kick" in message:
  950. if bot.getChatMember(chat_id, 353129131) in bot.getChatAdministrators(chat_id):
  951. if bot.getChatMember(chat_id,
  952. msg['reply_to_message']['from']['id']) in bot.getChatAdministrators(
  953. chat_id):
  954. bot.sendMessage(chat_id, "I can't kick admins. Sorry!")
  955. else:
  956. bot.sendMessage(chat_id,
  957. msg['reply_to_message']['from']['first_name'] + " has been kicked by " +
  958. msg['from'][
  959. 'first_name'] + ".")
  960. bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
  961. bot.unbanChatMember(chat_id, msg['reply_to_message']['from']['id'])
  962. else:
  963. bot.sendMessage(chat_id, "Error: I need to be admin.")
  964. if isPrivateMessage == False:
  965. if message.startswith("/title"):
  966. try:
  967. bot.setChatTitle(chat_id, str(msg['text'][7:]))
  968. except:
  969. bot.sendMessage(chat_id, "An error has occurred")
  970. if "/byebot" in message:
  971. bot.sendMessage(chat_id, "Bye! If you had any issues, contact @spoon. Thanks!")
  972. bot.leaveChat(chat_id)
  973. else:
  974. bot.sendMessage(chat_id, "Sorry.. I will leave you alone :( PM whenever")
  975. if isPrivateMessage == False:
  976. if "/warn" in message:
  977. if bot.getChatMember(chat_id, 353129131) in bot.getChatAdministrators(chat_id):
  978. if bot.getChatMember(chat_id,
  979. msg['reply_to_message']['from']['id']) in bot.getChatAdministrators(
  980. chat_id):
  981. bot.sendMessage(chat_id, "Admins can not get warned.")
  982. else:
  983. if os.path.isfile(str(chat_id) + "/data/" + str(
  984. msg['reply_to_message']['from']['id']) + ".txt") == False:
  985. filet = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "w")
  986. filew = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt")
  987. filer = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r")
  988. filee = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r+")
  989. filet.write("1")
  990. bot.sendMessage(chat_id, "You have been warned by " + str(msg['from']['first_name']) + " *(1/3)*", parse_mode="markdown")
  991.  
  992. open("data/temp.txt", "w").write(str(msg['reply_to_message']['from']['id']))
  993. global warnd
  994. else:
  995. if "1" in open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r"):
  996. open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "w").write(
  997. "2")
  998. bot.sendMessage(chat_id, "You have been warned by " + str(
  999. msg['from']['first_name']) + " *(2/3)*", parse_mode="markdown")
  1000.  
  1001. open(str(chat_id) + "/data/temp.txt", "w").write(str(msg['reply_to_message']['from']['id']))
  1002. elif "2" in open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1003. "r"):
  1004. open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "w").write(
  1005. "3")
  1006. bot.sendMessage(chat_id, "You exceeded warn limit, you are now banned. *(3/3)*",
  1007. parse_mode="markdown")
  1008. bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
  1009. os.remove(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1010. open(str(chat_id) + "/data/temp.txt", "w").write(str(msg['reply_to_message']['from']['id']))
  1011. else:
  1012. bot.sendMessage(chat_id, "Don't forget to admin me!")
  1013. if "/photo" in message:
  1014. if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
  1015. open(str(chat_id) + "/data/photo.txt", "w").write("False")
  1016. bot.sendMessage(chat_id, "I will no longer edit photos")
  1017. else:
  1018. open(str(chat_id) + "/data/photo.txt", "w").write("True")
  1019. bot.sendMessage(chat_id, "I will now edit photos")
  1020. if "/wel " in message:
  1021. if "Photo" in open(str(chat_id) + "/data/greet.txt", "r"):
  1022. if len(msg['text'][5:]) > 15:
  1023. bot.sendMessage(chat_id, "This message is too long for a picture message, please try again. Or switch to text by typing /greet")
  1024. else:
  1025. open(str(chat_id) + "/data/greettext.txt", "w").write(msg['text'][5:])
  1026. bot.sendMessage(chat_id, "Welcome message set!")
  1027. else:
  1028. if "True" in open(str(chat_id) + "/wel.txt").read():
  1029. open(str(chat_id) + "/welcome.txt", "w").write(msg['text'][5:])
  1030. bot.sendMessage(chat_id, "Welcome message set!")
  1031. else:
  1032. bot.sendMessage(chat_id, "Welcome messages have been disabled. To re-enable them, type /wt")
  1033. if "/pin" in message:
  1034. if 'reply_to_message' in msg:
  1035. bot.pinChatMessage(chat_id, msg['reply_to_message']['message_id'],
  1036. disable_notification=True)
  1037. telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
  1038. else:
  1039. bot.sendMessage(chat_id, "Reply to message.")
  1040. if "/wt" in message:
  1041. if "True" in open(str(chat_id) + "/wel.txt", "r"):
  1042. open(str(chat_id) + "/wel.txt", "w").write("False")
  1043. bot.sendMessage(chat_id, "Welcome messages have been disabled.")
  1044. else:
  1045. open(str(chat_id) + "/wel.txt", "w").write("True")
  1046. bot.sendMessage(chat_id, "Welcome messages have been enabled.")
  1047. if "/gt" in message:
  1048. if "True" in open(str(chat_id) + "/data/games.txt", "r"):
  1049. open(str(chat_id) + "/data/games.txt", "w").write("False")
  1050. bot.sendMessage(chat_id, "Games have been disabled.")
  1051. else:
  1052. open(str(chat_id) + "/data/games.txt", "w").write("True")
  1053. bot.sendMessage(chat_id, "Games have been enabled.")
  1054. if "/rt" in message:
  1055. if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
  1056. open(str(chat_id) + "/data/roll.txt", "w").write("False")
  1057. bot.sendMessage(chat_id, "I will no longer roll dice.")
  1058. else:
  1059. open(str(chat_id) + "/data/roll.txt", "w").write("True")
  1060. bot.sendMessage(chat_id, "I will now roll dice.")
  1061. if "/jt" in message:
  1062. if "True" in open(str(chat_id) + "/data/jokes.txt", "r"):
  1063. open(str(chat_id) + "/data/jokes.txt", "w").write("False")
  1064. bot.sendMessage(chat_id, "I will no longer tell jokes.")
  1065. else:
  1066. open(str(chat_id) + "/data/jokes.txt", "w").write("True")
  1067. bot.sendMessage(chat_id, "I will now tell jokes.")
  1068. if "/eb" in message:
  1069. if "True" in open(str(chat_id) + "/data/8ball.txt", "r"):
  1070. open(str(chat_id) + "/data/8ball.txt", "w").write("False")
  1071. bot.sendMessage(chat_id, "I will no longer answer questions.")
  1072. else:
  1073. open(str(chat_id) + "/data/8ball.txt", "w").write("True")
  1074. bot.sendMessage(chat_id, "I will no answer questions.")
  1075. if "/greet" in message:
  1076. if "Text" in open(str(chat_id) + "/data/greet.txt", "r"):
  1077. open(str(chat_id) + "/data/greet.txt", "w").write("Photo")
  1078. bot.sendMessage(chat_id, "I will now greet with photo.")
  1079. else:
  1080. open(str(chat_id) + "/data/greet.txt", "w").write("Text")
  1081. bot.sendMessage(chat_id, "I will now greet with text.")
  1082. if message == "/wel":
  1083. if "True" in open(str(chat_id) + "/wel.txt").read():
  1084. bot.sendMessage(chat_id,"To set a message, type '/wel Welcome message.'\n$u = Username\n$n = User's name\n$t = Title")
  1085. else:
  1086. bot.sendMessage(chat_id, "Welcome messages have been disabled. To re-enable them, type /wt")
  1087. if "/reset" in message:
  1088. if bot.getChatMember(chat_id, 353129131) in bot.getChatAdministrators(chat_id):
  1089. if os.path.isfile(str(chat_id) + "/data/" + str(
  1090. msg['reply_to_message']['from']['id']) + ".txt") == True:
  1091. os.remove(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1092. bot.sendMessage(chat_id, "Poof! All warns have been removed.")
  1093. else:
  1094. bot.sendMessage(chat_id, "This user has no warns.")
  1095. if "/toggles" in message:
  1096. t = threading.Thread(target=toggle)
  1097. t.start()
  1098. if "/give " in message:
  1099. if "reply_to_message" in msg:
  1100. if msg['reply_to_message']['from']['id'] != messageFromID:
  1101. if "-" in message[6:]:
  1102. bot.sendMessage(chat_id, "lol nice try")
  1103. else:
  1104. if re.search('[a-zA-Z]', message[6:]):
  1105. bot.sendMessage(chat_id, "Can't send letters?")
  1106. print(
  1107. str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace("[",
  1108. "").replace(
  1109. "'", "").replace("]", ""))
  1110. else:
  1111. if int(str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
  1112. "[",
  1113. "").replace(
  1114. "'", "").replace("]", "")) == int(str(msg['text'][6:])):
  1115. minus = int(
  1116. str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
  1117. "[",
  1118. "").replace(
  1119. "'", "").replace("]", "")) - int(str(msg['text'][6:]))
  1120. add = int(
  1121. str(open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
  1122. "r").readlines()).replace("[", "").replace(
  1123. "'", "").replace("]", "")) + int(message[6:])
  1124. open("rooms/" + str(messageFromID) + "money.txt", "w").write("0")
  1125. open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
  1126. "w").write(
  1127. str(add))
  1128. bot.sendMessage(chat_id, "Sent *" + str(msg['text'][6:]) + "* coins!",
  1129. parse_mode="markdown")
  1130. elif int(str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
  1131. "[",
  1132. "").replace(
  1133. "'", "").replace("]", "")) > int(str(msg['text'][6:])):
  1134. minus = int(
  1135. str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
  1136. "[",
  1137. "").replace(
  1138. "'", "").replace("]", "")) - int(str(msg['text'][6:]))
  1139. add = int(
  1140. str(open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
  1141. "r").readlines()).replace("[", "").replace(
  1142. "'", "").replace("]", "")) + int(message[6:])
  1143. open("rooms/" + str(messageFromID) + "money.txt", "w").write(str(minus))
  1144. open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
  1145. "w").write(
  1146. str(add))
  1147. bot.sendMessage(chat_id, "Sent *" + str(msg['text'][6:]) + "* coins!",
  1148. parse_mode="markdown")
  1149. else:
  1150. bot.sendMessage(chat_id, "You don't have enough money.")
  1151. else:
  1152. bot.sendMessage(chat_id, "lol nice try")
  1153. if "/jokes" in message:
  1154. if "True" in open(str(chat_id) + "/data/jokes.txt", "r"):
  1155. bot.sendMessage(chat_id, random.choice(jokes))
  1156. def define():
  1157. heart = u'\u2764'
  1158. term = msg['text'][4:]
  1159. if term == "spoon":
  1160. bot.sendMessage(chat_id, "The creator of this bot @spoon" + heart)
  1161. elif term == "panda":
  1162. bot.sendMessage(chat_id,
  1163. "*Panda:*\n\nPanda is an emotional crybaby but she is also heartless and has _no_ feelings. Other than that, she is a good friend to people who deserve it.",
  1164. parse_mode="markdown")
  1165. elif term == "ella":
  1166. bot.sendMessage(chat_id,
  1167. "*Ella:*\n\nElla is very unpredictable. She is the sweetest meanest person you'll ever meet. Sometimes she does things she can't even understand herself, but she isn't stupid. She can also be a harsh and ruthless mean bitch if she wants to, but naturally she is sweet to all.",
  1168. parse_mode="markdown")
  1169. elif term == "awais":
  1170. bot.sendMessage(chat_id,
  1171. "*Awais:*\n\nOne word. Telegod.",
  1172. parse_mode="markdown")
  1173. else:
  1174. term = message.lower()[4:]
  1175. definition = urbandict.define(term)[0]['def']
  1176. bot.sendMessage(chat_id, "*" + term + "*:\n\n" + definition, parse_mode="markdown")
  1177. if "/ud " in message:
  1178. t = threading.Thread(target=define)
  1179. term = msg['text'][4:]
  1180. t.start()
  1181. slapr = ['$q was split from crotch to sternum by $w.', "$q was busted.", "$q was sawn in half by $w.", "$q fell out of the world.", "$q was killed by $w using magic.", "$q fell off a ladder.", "$q withered away.", "$w put $q in check-mate.", "$q played hot-potato with a grenade.", "$q was axe-murdered by $w", "$q was squashed by a falling anvil.", "$q has encountered an error", "$w slapped $q with pure nothing", "$q escaped infection by dying.", "$q suffocated in a wall.", "$q was terminated by $w.", "$q was not invincible.", "$q got finished off by $w", "$q fell from a high place because of $w.", "$q was knocked into the void by $w", "$w threw $q off a building."]
  1182. slap = ['$q was split from crotch to sternum.', "$q was busted.", "$q was sawn in half.", "$q fell out of the world.", "$q was killed by magic.", "$q fell off a ladder.", "$q withered away.", "$q was put in check-mate.", "$q played hot-potato with a grenade.", "$q was axe-murdered", "$q was squashed by a falling anvil.", "$q has encountered an error", "$q was slapped with pure nothing", "$q escaped infection by dying.", "$q suffocated in a wall.", "$q was terminated", "$q was not invincible.", "$q got finished off", "$q fell from a high place", "$q was knocked into the void", "$q was thrown off a building."]
  1183. if "/google " in message:
  1184. google = msg['text'][8:]
  1185. bot.sendMessage(chat_id, "[" + str(google) + "](https://www.google.com/#q=" + str(google).replace(" ",
  1186. "+") + ")",
  1187. parse_mode="markdown", disable_web_page_preview=True)
  1188. if "/slap" in message:
  1189. if "reply_to_message" in msg:
  1190. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  1191. name = str(msg['from']['first_name'])
  1192. else:
  1193. name = str(open("data/n" + str(messageFromID) + ".txt").read())
  1194. if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == False:
  1195. namer = str(msg['reply_to_message']['from']['first_name'])
  1196. else:
  1197. namer = str(open("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt").read())
  1198. bot.sendMessage(chat_id, str(random.choice(slapr)).replace("$q", namer).replace("$w", name), reply_to_message_id=msg['message_id'])
  1199. else:
  1200. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  1201. name = str(msg['from']['first_name'])
  1202. else:
  1203. name = str(open("data/n" + str(messageFromID) + ".txt").read())
  1204. bot.sendMessage(chat_id, str(random.choice(slap)).replace("$q", name), reply_to_message_id=msg['message_id'])
  1205. if message == '/def':
  1206. bot.sendMessage(chat_id, "Usage: /def <term>")
  1207. if messageType != 'private':
  1208. if "/scramble" in message:
  1209. if "True" in open(str(chat_id) + "/data/games.txt", "r").read():
  1210. if "False" in open(str(chat_id) + "/data/scramble.txt", "r").read():
  1211. open(str(chat_id) + "/data/scramble.txt", "w").write('True')
  1212. else:
  1213. bot.sendMessage(chat_id, "Game in progress!!")
  1214.  
  1215. def scramble():
  1216. open(str(chat_id) + "/data/scramble.txt", "w").write('inprogress')
  1217. rw = RandomWords()
  1218. word = rw.random_word()
  1219. open(str(chat_id) + "/data/word.txt", "w").write(str(word))
  1220. global word
  1221. words = ''.join(random.sample(word, len(word)))
  1222. bot.sendMessage(chat_id, "The word to unscramble is:\n*" + str(words) + "*", parse_mode="markdown")
  1223. print(word)
  1224. endTime = datetime.datetime.now() + datetime.timedelta(seconds=int(open(str(chat_id) + "/data/gamelimit.txt").read()))
  1225. while True:
  1226. if "inprogress" in open(str(chat_id) + "/data/scramble.txt", "r").read():
  1227. if datetime.datetime.now() >= endTime:
  1228. bot.sendMessage(chat_id, "Times up word is *" + str(word) + "*", parse_mode="markdown")
  1229. open(str(chat_id) + "/data/scramble.txt", "w").write('False')
  1230. break
  1231. else:
  1232. break
  1233. if messageType != 'private':
  1234. if "True" in open(str(chat_id) + "/data/scramble.txt", "r").read():
  1235. t = threading.Thread(target=scramble)
  1236. t.start()
  1237. if "inprogress" in open(str(chat_id) + "/data/scramble.txt", "r").read():
  1238. if open(str(chat_id) + "/data/word.txt").read() in message:
  1239. write = int(
  1240. str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace("[",
  1241. "").replace(
  1242. "'", "").replace("]", "")) + int(len(word) * 20)
  1243. write2 = int(
  1244. str(open("rooms/" + str(messageFromID) + "wins.txt", "r").readlines()).replace("[",
  1245. "").replace(
  1246. "'", "").replace("]", "")) + int(1)
  1247. bot.sendMessage(chat_id, str(msg['from']['first_name']) + " wins!")
  1248. open("rooms/" + str(messageFromID) + "wins.txt", "w").write(str(write2))
  1249. open(str(chat_id) + "/data/scramble.txt", "w").write('False')
  1250. open("rooms/" + str(messageFromID) + "money.txt", "w").write(str(write))
  1251. if message in commandsList:
  1252. if message in message:
  1253. cont = True
  1254. if cont:
  1255. if message == "hey bot":
  1256. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  1257. bot.sendMessage(chat_id, "Hi, " + msg['from']['first_name'][:15] + "!")
  1258. else:
  1259. bot.sendMessage(chat_id, "Hi, " + open("data/n" + str(messageFromID) + ".txt").read() + "!")
  1260. def picturemessage():
  1261. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  1262. try:
  1263. color = open(str(chat_id) + "/data/imagecolor.txt").read()
  1264. color1 = open(str(chat_id) + "/data/textcolor.txt").read()
  1265. profiles = bot.getUserProfilePhotos(msg['new_chat_member']['id'])
  1266. file_id = profiles['photos'][0][2]['file_id']
  1267. filename = str(msg['new_chat_member']['id']) + ".jpg"
  1268. bot.download_file(file_id, filename)
  1269. im = Image.open(filename)
  1270. img = PIL.Image.new("RGB", (640, 800), (color))
  1271. draw = PIL.ImageDraw.Draw(img)
  1272. font = ImageFont.truetype("DejaVuSans.ttf", int("65"))
  1273. except:
  1274. filename = "NoPFP.jpg"
  1275. im = Image.open(filename)
  1276. img = Image.new("RGB", (640, 800), (color))
  1277. draw = PIL.ImageDraw.Draw(img)
  1278. font = ImageFont.truetype("DejaVuSans.ttf", int("65"))
  1279. if os.path.isfile("data/n" + str(msg["new_chat_member"]['id']) + ".txt") == False:
  1280. if len(msg['from']['first_name']) > 15:
  1281. line2 = msg["new_chat_member"]['first_name'][:15] + "...!"
  1282. else:
  1283. line2 = msg['new_chat_member']['first_name'] + "!"
  1284. else:
  1285. if len(open("data/n" + str(msg["new_chat_member"]['id']) + ".txt").read()) > 15:
  1286. line2 = open("data/n" + str(msg["new_chat_member"]['id']) + ".txt").read()[:15] + "...!"
  1287. else:
  1288. line2 = open("data/n" + str(msg["new_chat_member"]['id']) + ".txt").read() + "!"
  1289. if os.path.isfile(str(chat_id) + "/data/greettext.txt") == False:
  1290. line1 = "Welcome"
  1291. else:
  1292. line1 = str(open(str(chat_id) + "/data/greettext.txt").read())
  1293. w, h = font.getsize(line1)
  1294. w2, h2 = font.getsize(line2)
  1295. draw.text(((650 - w) / 2, (1360 - h) / 2), line1, font=font, fill=str(color1))
  1296. draw.text(((650 - w2) / 2, ((1300 - h2) / 2) + 100), line2, font=font, fill=str(color1))
  1297. img.paste(im, (0, 0))
  1298. img.save("1" + filename)
  1299. bot.sendPhoto(chat_id, open("1" + filename, "rb"))
  1300. os.remove("1" + filename)
  1301. if filename != "NoPFP.jpg":
  1302. os.remove(filename)
  1303. if 'new_chat_member' in msg:
  1304. if 'username' in msg:
  1305. newuser = str("@" + msg['new_chat_member']['username'])
  1306. else:
  1307. newuser = msg['from']['first_name']
  1308. if 'new_chat_member' in msg:
  1309. newuser = msg['new_chat_member']['first_name']
  1310. print(msg['new_chat_member']['first_name'], "has joined", msg['chat']['title'])
  1311. if msg['new_chat_member']['id'] == 353129131:
  1312. bot.sendMessage(chat_id, "Hi, I am currently in beta. So if there are any bugs, PM @spoon xoxo")
  1313. else:
  1314. if 'True' in open(str(chat_id) + "/wel.txt").read():
  1315. if "Text" in open(str(chat_id) + "/data/greet.txt").read():
  1316. if os.path.isfile(str(chat_id) + "/welcome.txt") == False:
  1317. bot.sendMessage(chat_id,
  1318. "Welcome to the group! The welcome message has not been set. Type '/wel' and then your message. For more help, type /wel")
  1319. else:
  1320. if os.path.isfile("data/n" + str(msg['new_chat_member']['id']) + ".txt") == False:
  1321. f = open(str(chat_id) + "/welcome.txt").read().replace("$n",
  1322. msg['new_chat_member'][
  1323. 'first_name']).replace(
  1324. "$u",
  1325. newuser).replace("$t", msg['chat']['title'])
  1326. bot.sendMessage(chat_id, str(f))
  1327. else:
  1328. f = open(str(chat_id) + "/welcome.txt").read().replace("$n",
  1329. open("data/n" + str(
  1330. msg['new_chat_member']['id']) + ".txt").read()).replace(
  1331. "$u",
  1332. newuser).replace("$t", msg['chat']['title'])
  1333. bot.sendMessage(chat_id, str(f))
  1334. else:
  1335. t = threading.Thread(target=picturemessage)
  1336. t.start()
  1337. def check():
  1338. if messageType != 'private':
  1339. if bot.getChatMember(chat_id, messageFromID) in bot.getChatAdministrators(chat_id):
  1340. t = threading.Thread(target=admincom)
  1341. t.start()
  1342. else:
  1343. if str(messageFromID) in open(str(chat_id) + "/data/admin.txt", "r").read():
  1344. t = threading.Thread(target=admincom)
  1345. t.start()
  1346. if messageType != 'private':
  1347. t = threading.Thread(target=check)
  1348. t.start()
  1349. if "/callme " in message:
  1350. if len(message[8:]) > 25:
  1351. bot.sendMessage(chat_id, "The limit is 25 characters!")
  1352. elif "nothing" in message:
  1353. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  1354. bot.sendMessage(chat_id, "You currently have no nicknames, and I won't call you nothing :(")
  1355. else:
  1356. bot.sendMessage(chat_id, "Okay, I won't call you by any nicknames.")
  1357. os.remove("data/n" + str(messageFromID) + ".txt")
  1358. else:
  1359. if u"\u2B50" in message:
  1360. bot.sendMessage(chat_id, "You are trying to put a restricted emoji your name. This star is only for admins, please retry.")
  1361. else:
  1362. bot.sendMessage(chat_id, "Okay " + msg['text'][8:].replace(u"\u2B50", "") + ", I'll remember that.")
  1363. open("data/n" + str(messageFromID) + ".txt", "w").write(str(msg['text'][8:]).replace(u"\u2B50", ""))
  1364. if "/check" in message:
  1365. if messageType != 'private':
  1366. if 'reply_to_message' in msg:
  1367. if bot.getChatMember(chat_id, msg['reply_to_message']['from']['id']) in bot.getChatAdministrators(
  1368. chat_id):
  1369. star = u"\u2B50"
  1370. else:
  1371. if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt").read():
  1372. star = u"\u2B50"
  1373. else:
  1374. star = ""
  1375. if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == True:
  1376. name = open("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt").read()
  1377. else:
  1378. msg['from']['first_name'][:15]
  1379. if os.path.isfile(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt") == True:
  1380. Warns = str("Amount of warns: *(" + str(
  1381. open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1382. "r").read()) + "/3)*\n")
  1383. else:
  1384. Warns = ""
  1385. if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == False:
  1386. if " help" in message:
  1387. bot.sendMessage(chat_id,
  1388. "You can add links to your /check message by sending this:\n/check instagram <instagram username>\n/check reddit <reddit username>\n/check steam <steam username>\n/check location <location>\n/check snapchat <snapchat>\n/check soundcloud <soundcloud>")
  1389. if os.path.isfile(
  1390. ("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1391. Instagram = str("Instagram: [" + str(
  1392. open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1393. "r").read()) + "](https://www.instagram.com/" + str(
  1394. open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1395. "r").read()) + ")\n")
  1396. else:
  1397. Instagram = ""
  1398. if os.path.isfile(
  1399. ("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1400. Steam = str("Steam: [" + str(
  1401. open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1402. "r").read()) + "](http://steamcommunity.com/id/" + str(
  1403. open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1404. "r").read()) + ")\n")
  1405. else:
  1406. Steam = ""
  1407. if os.path.isfile(
  1408. ("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1409. Soundcloud = str("Soundcloud: [" + str(
  1410. open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1411. "r").read()) + "](https://soundcloud.com/" + str(
  1412. open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1413. "r").read()) + ")\n")
  1414. else:
  1415. Soundcloud = ""
  1416. if os.path.isfile(
  1417. ("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1418. Reddit = str(
  1419. "Reddit: [" + str(
  1420. open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1421. "r").read()) + "](https://www.reddit.com/user/" + str(
  1422. open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1423. "r").read()) + ")\n")
  1424. else:
  1425. Reddit = ""
  1426. if os.path.isfile(
  1427. ("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1428. Snapchat = str("Snapchat: [" + str(
  1429. open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1430. "r").read()) + "](https://www.snapchat.com/add/" + str(
  1431. open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1432. "r").read()) + ")\n")
  1433. else:
  1434. Snapchat = ""
  1435. if os.path.isfile(
  1436. ("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1437. Location = str("Location: [" + str(
  1438. open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1439. "r").read()) + "](https://www.google.com/#q=" + str(
  1440. open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1441. "r").read()).replace(" ", "+") + ")\n")
  1442. else:
  1443. Location = ""
  1444. usermessages = open(str(chat_id) + "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1445. "r").read()
  1446. groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
  1447. percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
  1448. print(percentage)
  1449. if message == "/check":
  1450. bot.sendMessage(chat_id,
  1451. "*" + msg['reply_to_message']['from']['first_name'] + " " + star + "*\n\nCoins: *" + str(
  1452. open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
  1453. "r").read()) + "\n*Wins: *" + str(
  1454. open("rooms/" + str(msg['reply_to_message']['from']['id']) + "wins.txt",
  1455. "r").read()) + "*\n%s%s%s%s%s%s%sYou've sent " % (
  1456. Warns,
  1457. Instagram, Reddit, Steam, Location, Soundcloud, Snapchat) + open(
  1458. str(chat_id) +
  1459. "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1460. "r").read() + " (" + str(
  1461. percentage) + "%) and this group has " + open(
  1462. str(chat_id) + "/messagecount.txt",
  1463. "r").read() + " messages.",
  1464. parse_mode="markdown", disable_web_page_preview=True)
  1465. else:
  1466. if os.path.isfile(str(chat_id) + "/data/" + str(
  1467. msg['reply_to_message']['from']['id']) + ".txt") == True:
  1468. Warns = str(
  1469. "Amount of warns: *(" + str(
  1470. open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1471. "r").read()) + "/3)*\n")
  1472. else:
  1473. Warns = ""
  1474. if " instagram " in message:
  1475. if "delete" in msg['text'][17:].lower():
  1476. os.remove("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1477. bot.sendMessage(chat_id, "Instagram removed!")
  1478. else:
  1479. if len(msg['text'][17:].lower()) > 15:
  1480. bot.sendMessage(chat_id, "Not a valid Instagram name.")
  1481. else:
  1482. open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1483. "w").write(
  1484. str(msg['text'][17:]))
  1485. bot.sendMessage(chat_id, "Instagram set!")
  1486. if " reddit " in message:
  1487. if "delete" in msg['text'][14:].lower():
  1488. os.remove("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1489. bot.sendMessage(chat_id, "Reddit removed!")
  1490. else:
  1491. if len(msg['text'][14:].lower()) > 15:
  1492. bot.sendMessage(chat_id, "Not a valid Reddit name.")
  1493. else:
  1494. open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1495. "w").write(
  1496. str(msg['text'][14:]))
  1497. bot.sendMessage(chat_id, "Reddit set!")
  1498. if " help" in message:
  1499. bot.sendMessage(chat_id,
  1500. "You can add links to your /check message by sending this:\n/check instagram <instagram username>\n/check reddit <reddit username>\n/check steam <steam username>\n/check location <location>")
  1501. if " steam " in message:
  1502. if "delete" in msg['text'][13:].lower():
  1503. os.remove("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1504. bot.sendMessage(chat_id, "Steam removed!")
  1505. else:
  1506. if len(msg['text'][13:].lower()) > 20:
  1507. bot.sendMessage(chat_id, "Not a valid Steam name.")
  1508. else:
  1509. open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1510. "w").write(
  1511. str(msg['text'][13:]))
  1512. bot.sendMessage(chat_id, "Steam set!")
  1513. if " soundcloud " in message:
  1514. if "delete" in msg['text'][13:].lower():
  1515. os.remove("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1516. bot.sendMessage(chat_id, "Steam removed!")
  1517. else:
  1518. if len(msg['text'][18:].lower()) > 20:
  1519. bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
  1520. else:
  1521. open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1522. "w").write(
  1523. str(msg['text'][18:]))
  1524. bot.sendMessage(chat_id, "Soundcloud set!")
  1525. if " location " in message:
  1526. if "delete" in msg['text'].lower():
  1527. os.remove("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1528. bot.sendMessage(chat_id, "Location removed!")
  1529. else:
  1530. if len(msg['text'].lower()) > 30:
  1531. bot.sendMessage(chat_id, "Not a valid Location name.")
  1532. else:
  1533. open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1534. "w").write(
  1535. str(msg['text'][15:]))
  1536. bot.sendMessage(chat_id, "Location set!")
  1537. if " snapchat " in message:
  1538. if "delete" in msg['text'][16:].lower():
  1539. os.remove("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt")
  1540. bot.sendMessage(chat_id, "Snapchat removed!")
  1541. else:
  1542. if len(msg['text'][16:].lower()) > 15:
  1543. bot.sendMessage(chat_id, "Not a valid Snapchat name.")
  1544. else:
  1545. open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1546. "w").write(
  1547. str(msg['text'][16:]))
  1548. bot.sendMessage(chat_id, "Snapchat set!")
  1549. if os.path.isfile(
  1550. ("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1551. Instagram = str("Instagram: [" + str(
  1552. open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1553. "r").read()) + "](https://www.instagram.com/" + str(
  1554. open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1555. "r").read()) + ")\n")
  1556. else:
  1557. Instagram = ""
  1558. if os.path.isfile(
  1559. ("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1560. Steam = str("Steam: [" + str(
  1561. open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1562. "r").read()) + "](http://steamcommunity.com/id/" + str(
  1563. open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1564. "r").read()) + ")\n")
  1565. else:
  1566. Steam = ""
  1567. if os.path.isfile(
  1568. ("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1569. Soundcloud = str("Soundcloud: [" + str(
  1570. open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1571. "r").read()) + "](https://soundcloud.com/" + str(
  1572. open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1573. "r").read()) + ")\n")
  1574. else:
  1575. Soundcloud = ""
  1576. if os.path.isfile(
  1577. ("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1578. Reddit = str(
  1579. "Reddit: [" + str(
  1580. open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1581. "r").read()) + "](https://www.reddit.com/user/" + str(
  1582. open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1583. "r").read()) + ")\n")
  1584. else:
  1585. Reddit = ""
  1586. if os.path.isfile(
  1587. ("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1588. Snapchat = str("Snapchat: [" + str(
  1589. open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1590. "r").read()) + "](https://www.snapchat.com/add/" + str(
  1591. open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1592. "r").read()) + ")\n")
  1593. else:
  1594. Snapchat = ""
  1595. if os.path.isfile(
  1596. ("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
  1597. Location = str("Location: [" + str(
  1598. open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1599. "r").read()) + "](https://www.google.com/#q=" + str(
  1600. open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1601. "r").read()).replace(" ", "+") + ")\n")
  1602. else:
  1603. Location = ""
  1604. usermessages = open(str(chat_id) + "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt",
  1605. "r").read()
  1606. groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
  1607. percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
  1608. print(percentage)
  1609. if message == "/check":
  1610. bot.sendMessage(chat_id, "*" + name + " " + star + "*\n\nCoins: *" + str(
  1611. open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
  1612. "r").read()) + "\n*Wins: *" + str(
  1613. open("rooms/" + str(msg['reply_to_message']['from']['id']) + "wins.txt",
  1614. "r").read()) + "*\n%s%s%s%s%s%s%sYou've sent " % (
  1615. Warns,
  1616. Instagram, Reddit, Steam, Location, Soundcloud, Snapchat) + open(
  1617. str(chat_id) +
  1618. "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read() + " (" + str(
  1619. percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
  1620. "r").read() + " messages.",
  1621. parse_mode="markdown", disable_web_page_preview=True)
  1622. else:
  1623. if bot.getChatMember(chat_id, messageFromID) in bot.getChatAdministrators(
  1624. chat_id):
  1625. star = u"\u2B50"
  1626. else:
  1627. if str(messageFromID) in open(str(chat_id) + "/data/admin.txt").read():
  1628. star = u"\u2B50"
  1629. else:
  1630. star = ""
  1631. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  1632. if " help" in message:
  1633. bot.sendMessage(chat_id,
  1634. "You can add links to your /check message by sending this:\n/check instagram <instagram username>\n/check reddit <reddit username>\n/check steam <steam username>\n/check location <location>")
  1635. if " instagram " in message:
  1636. if "delete" in msg['text'][11:].lower():
  1637. os.remove("data/insta" + str(messageFromID) + ".txt")
  1638. bot.sendMessage(chat_id, "Instagram removed!")
  1639. else:
  1640. if len(msg['text'][11:].lower()) > 15:
  1641. bot.sendMessage(chat_id, "Not a valid Instagram name.")
  1642. else:
  1643. open("data/insta" + str(messageFromID) + ".txt", "w").write(
  1644. str(msg['text'][17:]))
  1645. bot.sendMessage(chat_id, "Instagram set!")
  1646. if " reddit " in message:
  1647. if "delete" in msg['text'][11:].lower():
  1648. os.remove("data/red" + str(messageFromID) + ".txt")
  1649. bot.sendMessage(chat_id, "Reddit removed!")
  1650. else:
  1651. if len(msg['text'][11:].lower()) > 15:
  1652. bot.sendMessage(chat_id, "Not a valid Reddit name.")
  1653. else:
  1654. open("data/red" + str(messageFromID) + ".txt", "w").write(
  1655. str(msg['text'][14:]))
  1656. bot.sendMessage(chat_id, "Reddit set!")
  1657. if " steam " in message:
  1658. if "delete" in msg['text'][11:].lower():
  1659. os.remove("data/steam" + str(messageFromID) + ".txt")
  1660. bot.sendMessage(chat_id, "Steam removed!")
  1661. else:
  1662. if len(msg['text'][11:].lower()) > 20:
  1663. bot.sendMessage(chat_id, "Not a valid Steam name.")
  1664. else:
  1665. open("data/steam" + str(messageFromID) + ".txt", "w").write(
  1666. str(msg['text'][13:]))
  1667. bot.sendMessage(chat_id, "Steam set!")
  1668. if " soundcloud " in message:
  1669. if "delete" in msg['text'][13:].lower():
  1670. os.remove("data/soundcloud" + str(messageFromID) + ".txt")
  1671. bot.sendMessage(chat_id, "Steam removed!")
  1672. else:
  1673. if len(msg['text'][18:].lower()) > 20:
  1674. bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
  1675. else:
  1676. open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
  1677. str(msg['text'][18:]))
  1678. bot.sendMessage(chat_id, "Soundcloud set!")
  1679. if " snapchat " in message:
  1680. if "delete" in msg['text'][16:].lower():
  1681. os.remove("data/snapchat" + str(messageFromID) + ".txt")
  1682. bot.sendMessage(chat_id, "Snapchat removed!")
  1683. else:
  1684. if len(msg['text'][16:].lower()) > 15:
  1685. bot.sendMessage(chat_id, "Not a valid Snapchat name.")
  1686. else:
  1687. open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
  1688. str(msg['text'][16:]))
  1689. bot.sendMessage(chat_id, "Snapchat set!")
  1690.  
  1691. if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
  1692. Soundcloud = str("Soundcloud: [" + str(
  1693. open("data/soundcloud" + str(messageFromID) + ".txt",
  1694. "r").read()) + "](https://soundcloud.com/" + str(
  1695. open("data/soundcloud" + str(messageFromID) + ".txt",
  1696. "r").read()) + ")\n")
  1697. else:
  1698. Soundcloud = ""
  1699. if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
  1700. Snapchat = str("Snapchat: [" + str(
  1701. open("data/snapchat" + str(messageFromID) + ".txt",
  1702. "r").read()) + "](https://www.snapchat.com/add/" + str(
  1703. open("data/snapchat" + str(messageFromID) + ".txt",
  1704. "r").read()) + ")\n")
  1705. else:
  1706. Snapchat = ""
  1707. if " location " in message:
  1708. if "delete" in msg['text'][11:].lower():
  1709. os.remove("data/loc" + str(messageFromID) + ".txt")
  1710. bot.sendMessage(chat_id, "Location removed!")
  1711. else:
  1712. if len(msg['text'][11:].lower()) > 30:
  1713. bot.sendMessage(chat_id, "Not a valid Location name.")
  1714. else:
  1715. open("data/loc" + str(messageFromID) + ".txt", "w").write(
  1716. str(msg['text'][15:]))
  1717. bot.sendMessage(chat_id, "Location set!")
  1718. if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
  1719. Instagram = str(
  1720. "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
  1721. "r").read()) + "](https://www.instagram.com/" + str(
  1722. open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  1723. else:
  1724. Instagram = ""
  1725. if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
  1726. Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
  1727. "r").read()) + "](http://steamcommunity.com/id/" + str(
  1728. open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  1729. else:
  1730. Steam = ""
  1731. if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
  1732. Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
  1733. "r").read()) + "](https://www.reddit.com/user/" + str(
  1734. open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  1735. else:
  1736. Reddit = ""
  1737. if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
  1738. Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
  1739. "r").read()) + "](https://www.google.com/#q=" + str(
  1740. open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
  1741. "+") + ")\n")
  1742. else:
  1743. Location = ""
  1744. if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
  1745. Warns = str(
  1746. "Amount of warns: *(" + str(open(str(chat_id) + "/data/" + str(messageFromID) + ".txt",
  1747. "r").read()) + "/3)*\n")
  1748. else:
  1749. Warns = ""
  1750. usermessages = open(str(chat_id) + "/messages/" + str(messageFromID) + ".txt", "r").read()
  1751. groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
  1752. percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
  1753. print(percentage)
  1754. if message == "/check":
  1755. bot.sendMessage(chat_id, "*" + msg['from']['first_name'] + " " + star + "*\n\nCoins: *" + str(
  1756. open("rooms/" + str(messageFromID) + "money.txt",
  1757. "r").read()) + "\n*Wins: *" + str(
  1758. open("rooms/" + str(messageFromID) + "wins.txt",
  1759. "r").read()) + "*\n%s%s%s%s%s%s%sYou've sent " % (
  1760. Warns,
  1761. Instagram, Reddit, Steam, Location, Soundcloud, Snapchat) + open(
  1762. str(chat_id) +
  1763. "/messages/" + str(messageFromID) + ".txt", "r").read() + " (" + str(
  1764. percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
  1765. "r").read() + " messages.",
  1766. parse_mode="markdown", disable_web_page_preview=True)
  1767.  
  1768. else:
  1769. if bot.getChatMember(chat_id,
  1770. messageFromID) in bot.getChatAdministrators(chat_id):
  1771. star = u"\u2B50"
  1772. else:
  1773. if str(messageFromID) in open(str(chat_id) + "/data/admin.txt").read():
  1774. star = u"\u2B50"
  1775. else:
  1776. star = ""
  1777. if " help" in message:
  1778. bot.sendMessage(chat_id,
  1779. "You can add links to your /check message by sending this:\n/check instagram <instagram username>\n/check snapchat <snapchat username>\n/check soundcloud <soundcloud username>\n/check reddit <reddit username>\n/check steam <steam username>\n/check location <location>")
  1780.  
  1781. if " instagram " in message:
  1782. if "delete" in msg['text'][17:].lower():
  1783. os.remove("data/insta" + str(messageFromID) + ".txt")
  1784. bot.sendMessage(chat_id, "Instagram removed!")
  1785. else:
  1786. if len(msg['text'][17:].lower()) > 15:
  1787. bot.sendMessage(chat_id, "Not a valid Instagram name.")
  1788. else:
  1789. open("data/insta" + str(messageFromID) + ".txt", "w").write(
  1790. str(msg['text'][17:]))
  1791. bot.sendMessage(chat_id, "Instagram set!")
  1792. if " snapchat " in message:
  1793. if "delete" in msg['text'][16:].lower():
  1794. os.remove("data/snapchat" + str(messageFromID) + ".txt")
  1795. bot.sendMessage(chat_id, "Snapchat removed!")
  1796. else:
  1797. if len(msg['text'][16:].lower()) > 15:
  1798. bot.sendMessage(chat_id, "Not a valid Snapchat name.")
  1799. else:
  1800. open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
  1801. str(msg['text'][16:]))
  1802. bot.sendMessage(chat_id, "Snapchat set!")
  1803. if " reddit " in message:
  1804. if "delete" in msg['text'][14:].lower():
  1805. os.remove("data/red" + str(messageFromID) + ".txt")
  1806. bot.sendMessage(chat_id, "Reddit removed!")
  1807. else:
  1808. if len(msg['text'][14:].lower()) > 15:
  1809. bot.sendMessage(chat_id, "Not a valid Reddit name.")
  1810. else:
  1811. open("data/red" + str(messageFromID) + ".txt", "w").write(
  1812. str(msg['text'][14:]))
  1813. bot.sendMessage(chat_id, "Reddit set!")
  1814. if " soundcloud " in message:
  1815. if "delete" in msg['text'][13:].lower():
  1816. os.remove("data/soundcloud" + str(messageFromID) + ".txt")
  1817. bot.sendMessage(chat_id, "Steam removed!")
  1818. else:
  1819. if len(msg['text'][18:].lower()) > 20:
  1820. bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
  1821. else:
  1822. open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
  1823. str(msg['text'][18:]))
  1824. bot.sendMessage(chat_id, "Soundcloud set!")
  1825. if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
  1826. Soundcloud = str("Soundcloud: [" + str(
  1827. open("data/soundcloud" + str(messageFromID) + ".txt",
  1828. "r").read()) + "](https://soundcloud.com/" + str(
  1829. open("data/soundcloud" + str(messageFromID) + ".txt",
  1830. "r").read()) + ")\n")
  1831. else:
  1832. Soundcloud = ""
  1833. if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
  1834. Snapchat = str("Snapchat: [" + str(
  1835. open("data/snapchat" + str(messageFromID) + ".txt",
  1836. "r").read()) + "](https://www.snapchat.com/add/" + str(
  1837. open("data/snapchat" + str(messageFromID) + ".txt",
  1838. "r").read()) + ")\n")
  1839. else:
  1840. Snapchat = ""
  1841. if " steam " in message:
  1842. if "delete" in msg['text'][13:].lower():
  1843. os.remove("data/steam" + str(messageFromID) + ".txt")
  1844. bot.sendMessage(chat_id, "Steam removed!")
  1845. else:
  1846. if len(msg['text'][13:].lower()) > 20:
  1847. bot.sendMessage(chat_id, "Not a valid Steam name.")
  1848. else:
  1849. open("data/steam" + str(messageFromID) + ".txt", "w").write(
  1850. str(msg['text'][13:]))
  1851. bot.sendMessage(chat_id, "Steam set!")
  1852. if " location " in message:
  1853. if "delete" in msg['text'].lower():
  1854. os.remove("data/loc" + str(messageFromID) + ".txt")
  1855. bot.sendMessage(chat_id, "Location removed!")
  1856. else:
  1857. if len(msg['text'].lower()) > 30:
  1858. bot.sendMessage(chat_id, "Not a valid Location name.")
  1859. else:
  1860. open("data/loc" + str(messageFromID) + ".txt", "w").write(
  1861. str(msg['text'][15:]))
  1862. bot.sendMessage(chat_id, "Location set!")
  1863. if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
  1864. Instagram = str(
  1865. "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
  1866. "r").read()) + "](https://www.instagram.com/" + str(
  1867. open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  1868. else:
  1869. Instagram = ""
  1870. if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
  1871. Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
  1872. "r").read()) + "](http://steamcommunity.com/id/" + str(
  1873. open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  1874. else:
  1875. Steam = ""
  1876. if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
  1877. Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
  1878. "r").read()) + "](https://www.reddit.com/user/" + str(
  1879. open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  1880. else:
  1881. Reddit = ""
  1882. if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
  1883. Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
  1884. "r").read()) + "](https://www.google.com/#q=" + str(
  1885. open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
  1886. "+") + ")\n")
  1887. else:
  1888. Location = ""
  1889. if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
  1890. Warns = str(
  1891. "Amount of warns: *(" + str(
  1892. open(str(chat_id) + "/data/" + str(messageFromID) + ".txt", "r").read()) + "/3)*\n")
  1893. else:
  1894. Warns = ""
  1895. usermessages = open(str(chat_id) + "/messages/" + str(messageFromID) + ".txt", "r").read()
  1896. groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
  1897. percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
  1898. print(percentage)
  1899. if message == "/check":
  1900. bot.sendMessage(chat_id, "*" + open(
  1901. "data/n" + str(messageFromID) + ".txt").read() + " " + star + "*\n\nCoins: *" + str(
  1902. open("rooms/" + str(messageFromID) + "money.txt",
  1903. "r").read()) + "\n*Wins: *" + str(
  1904. open("rooms/" + str(messageFromID) + "wins.txt",
  1905. "r").read()) + "*\n%s%s%s%s%s%s%sYou've sent " % (
  1906. Warns,
  1907. Instagram, Reddit, Steam, Location, Soundcloud, Snapchat) + open(str(chat_id) +
  1908. "/messages/" + str(
  1909. messageFromID) + ".txt", "r").read() + " (" + str(
  1910. percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
  1911. "r").read() + " messages.",
  1912. parse_mode="markdown", disable_web_page_preview=True)
  1913. else:
  1914. star = ""
  1915. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  1916. if " help" in message:
  1917. bot.sendMessage(chat_id,
  1918. "You can add links to your /check message by sending this:\n/check instagram <instagram username>\n/check reddit <reddit username>\n/check steam <steam username>\n/check location <location>")
  1919. if " instagram " in message:
  1920. if "delete" in msg['text'][11:].lower():
  1921. os.remove("data/insta" + str(messageFromID) + ".txt")
  1922. bot.sendMessage(chat_id, "Instagram removed!")
  1923. else:
  1924. if len(msg['text'][11:].lower()) > 15:
  1925. bot.sendMessage(chat_id, "Not a valid Instagram name.")
  1926. else:
  1927. open("data/insta" + str(messageFromID) + ".txt", "w").write(
  1928. str(msg['text'][17:]))
  1929. bot.sendMessage(chat_id, "Instagram set!")
  1930. if " reddit " in message:
  1931. if "delete" in msg['text'][11:].lower():
  1932. os.remove("data/red" + str(messageFromID) + ".txt")
  1933. bot.sendMessage(chat_id, "Reddit removed!")
  1934. else:
  1935. if len(msg['text'][11:].lower()) > 15:
  1936. bot.sendMessage(chat_id, "Not a valid Reddit name.")
  1937. else:
  1938. open("data/red" + str(messageFromID) + ".txt", "w").write(
  1939. str(msg['text'][14:]))
  1940. bot.sendMessage(chat_id, "Reddit set!")
  1941. if " steam " in message:
  1942. if "delete" in msg['text'][11:].lower():
  1943. os.remove("data/steam" + str(messageFromID) + ".txt")
  1944. bot.sendMessage(chat_id, "Steam removed!")
  1945. else:
  1946. if len(msg['text'][11:].lower()) > 20:
  1947. bot.sendMessage(chat_id, "Not a valid Steam name.")
  1948. else:
  1949. open("data/steam" + str(messageFromID) + ".txt", "w").write(
  1950. str(msg['text'][13:]))
  1951. bot.sendMessage(chat_id, "Steam set!")
  1952. if " soundcloud " in message:
  1953. if "delete" in msg['text'][13:].lower():
  1954. os.remove("data/soundcloud" + str(messageFromID) + ".txt")
  1955. bot.sendMessage(chat_id, "Steam removed!")
  1956. else:
  1957. if len(msg['text'][18:].lower()) > 20:
  1958. bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
  1959. else:
  1960. open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
  1961. str(msg['text'][18:]))
  1962. bot.sendMessage(chat_id, "Soundcloud set!")
  1963. if " snapchat " in message:
  1964. if "delete" in msg['text'][16:].lower():
  1965. os.remove("data/snapchat" + str(messageFromID) + ".txt")
  1966. bot.sendMessage(chat_id, "Snapchat removed!")
  1967. else:
  1968. if len(msg['text'][16:].lower()) > 15:
  1969. bot.sendMessage(chat_id, "Not a valid Snapchat name.")
  1970. else:
  1971. open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
  1972. str(msg['text'][16:]))
  1973. bot.sendMessage(chat_id, "Snapchat set!")
  1974.  
  1975. if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
  1976. Soundcloud = str("Soundcloud: [" + str(
  1977. open("data/soundcloud" + str(messageFromID) + ".txt",
  1978. "r").read()) + "](https://soundcloud.com/" + str(
  1979. open("data/soundcloud" + str(messageFromID) + ".txt",
  1980. "r").read()) + ")\n")
  1981. else:
  1982. Soundcloud = ""
  1983. if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
  1984. Snapchat = str("Snapchat: [" + str(
  1985. open("data/snapchat" + str(messageFromID) + ".txt",
  1986. "r").read()) + "](https://www.snapchat.com/add/" + str(
  1987. open("data/snapchat" + str(messageFromID) + ".txt",
  1988. "r").read()) + ")\n")
  1989. else:
  1990. Snapchat = ""
  1991. if " location " in message:
  1992. if "delete" in msg['text'][11:].lower():
  1993. os.remove("data/loc" + str(messageFromID) + ".txt")
  1994. bot.sendMessage(chat_id, "Location removed!")
  1995. else:
  1996. if len(msg['text'][11:].lower()) > 30:
  1997. bot.sendMessage(chat_id, "Not a valid Location name.")
  1998. else:
  1999. open("data/loc" + str(messageFromID) + ".txt", "w").write(
  2000. str(msg['text'][15:]))
  2001. bot.sendMessage(chat_id, "Location set!")
  2002. if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
  2003. Instagram = str(
  2004. "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
  2005. "r").read()) + "](https://www.instagram.com/" + str(
  2006. open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  2007. else:
  2008. Instagram = ""
  2009. if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
  2010. Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
  2011. "r").read()) + "](http://steamcommunity.com/id/" + str(
  2012. open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  2013. else:
  2014. Steam = ""
  2015. if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
  2016. Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
  2017. "r").read()) + "](https://www.reddit.com/user/" + str(
  2018. open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  2019. else:
  2020. Reddit = ""
  2021. if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
  2022. Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
  2023. "r").read()) + "](https://www.google.com/#q=" + str(
  2024. open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
  2025. "+") + ")\n")
  2026. else:
  2027. Location = ""
  2028. if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
  2029. Warns = str(
  2030. "Amount of warns: *(" + str(open(str(chat_id) + "/data/" + str(messageFromID) + ".txt",
  2031. "r").read()) + "/3)*\n")
  2032. else:
  2033. Warns = ""
  2034. if message == "/check":
  2035. bot.sendMessage(chat_id, "*" + msg['from']['first_name'] + " " + star + "*\n\nCoins: *" + str(
  2036. open("rooms/" + str(messageFromID) + "money.txt",
  2037. "r").read()) + "\n*Wins: *" + str(
  2038. open("rooms/" + str(messageFromID) + "wins.txt",
  2039. "r").read()) + "*\n%s%s%s%s%s%s%s" % (
  2040. Warns,
  2041. Instagram, Reddit, Steam, Location, Soundcloud, Snapchat), parse_mode="markdown", disable_web_page_preview=True)
  2042.  
  2043. else:
  2044. star = ""
  2045. if " help" in message:
  2046. bot.sendMessage(chat_id,
  2047. "You can add links to your /check message by sending this:\n/check instagram <instagram username>\n/check snapchat <snapchat username>\n/check soundcloud <soundcloud username>\n/check reddit <reddit username>\n/check steam <steam username>\n/check location <location>")
  2048.  
  2049. if " instagram " in message:
  2050. if "delete" in msg['text'][17:].lower():
  2051. os.remove("data/insta" + str(messageFromID) + ".txt")
  2052. bot.sendMessage(chat_id, "Instagram removed!")
  2053. else:
  2054. if len(msg['text'][17:].lower()) > 15:
  2055. bot.sendMessage(chat_id, "Not a valid Instagram name.")
  2056. else:
  2057. open("data/insta" + str(messageFromID) + ".txt", "w").write(
  2058. str(msg['text'][17:]))
  2059. bot.sendMessage(chat_id, "Instagram set!")
  2060. if " snapchat " in message:
  2061. if "delete" in msg['text'][16:].lower():
  2062. os.remove("data/snapchat" + str(messageFromID) + ".txt")
  2063. bot.sendMessage(chat_id, "Snapchat removed!")
  2064. else:
  2065. if len(msg['text'][16:].lower()) > 15:
  2066. bot.sendMessage(chat_id, "Not a valid Snapchat name.")
  2067. else:
  2068. open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
  2069. str(msg['text'][16:]))
  2070. bot.sendMessage(chat_id, "Snapchat set!")
  2071. if " reddit " in message:
  2072. if "delete" in msg['text'][14:].lower():
  2073. os.remove("data/red" + str(messageFromID) + ".txt")
  2074. bot.sendMessage(chat_id, "Reddit removed!")
  2075. else:
  2076. if len(msg['text'][14:].lower()) > 15:
  2077. bot.sendMessage(chat_id, "Not a valid Reddit name.")
  2078. else:
  2079. open("data/red" + str(messageFromID) + ".txt", "w").write(
  2080. str(msg['text'][14:]))
  2081. bot.sendMessage(chat_id, "Reddit set!")
  2082. if " soundcloud " in message:
  2083. if "delete" in msg['text'][13:].lower():
  2084. os.remove("data/soundcloud" + str(messageFromID) + ".txt")
  2085. bot.sendMessage(chat_id, "Steam removed!")
  2086. else:
  2087. if len(msg['text'][18:].lower()) > 20:
  2088. bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
  2089. else:
  2090. open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
  2091. str(msg['text'][18:]))
  2092. bot.sendMessage(chat_id, "Soundcloud set!")
  2093. if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
  2094. Soundcloud = str("Soundcloud: [" + str(
  2095. open("data/soundcloud" + str(messageFromID) + ".txt",
  2096. "r").read()) + "](https://soundcloud.com/" + str(
  2097. open("data/soundcloud" + str(messageFromID) + ".txt",
  2098. "r").read()) + ")\n")
  2099. else:
  2100. Soundcloud = ""
  2101. if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
  2102. Snapchat = str("Snapchat: [" + str(
  2103. open("data/snapchat" + str(messageFromID) + ".txt",
  2104. "r").read()) + "](https://www.snapchat.com/add/" + str(
  2105. open("data/snapchat" + str(messageFromID) + ".txt",
  2106. "r").read()) + ")\n")
  2107. else:
  2108. Snapchat = ""
  2109. if " steam " in message:
  2110. if "delete" in msg['text'][13:].lower():
  2111. os.remove("data/steam" + str(messageFromID) + ".txt")
  2112. bot.sendMessage(chat_id, "Steam removed!")
  2113. else:
  2114. if len(msg['text'][13:].lower()) > 20:
  2115. bot.sendMessage(chat_id, "Not a valid Steam name.")
  2116. else:
  2117. open("data/steam" + str(messageFromID) + ".txt", "w").write(
  2118. str(msg['text'][13:]))
  2119. bot.sendMessage(chat_id, "Steam set!")
  2120. if " location " in message:
  2121. if "delete" in msg['text'].lower():
  2122. os.remove("data/loc" + str(messageFromID) + ".txt")
  2123. bot.sendMessage(chat_id, "Location removed!")
  2124. else:
  2125. if len(msg['text'].lower()) > 30:
  2126. bot.sendMessage(chat_id, "Not a valid Location name.")
  2127. else:
  2128. open("data/loc" + str(messageFromID) + ".txt", "w").write(
  2129. str(msg['text'][15:]))
  2130. bot.sendMessage(chat_id, "Location set!")
  2131. if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
  2132. Instagram = str(
  2133. "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
  2134. "r").read()) + "](https://www.instagram.com/" + str(
  2135. open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  2136. else:
  2137. Instagram = ""
  2138. if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
  2139. Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
  2140. "r").read()) + "](http://steamcommunity.com/id/" + str(
  2141. open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  2142. else:
  2143. Steam = ""
  2144. if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
  2145. Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
  2146. "r").read()) + "](https://www.reddit.com/user/" + str(
  2147. open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
  2148. else:
  2149. Reddit = ""
  2150. if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
  2151. Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
  2152. "r").read()) + "](https://www.google.com/#q=" + str(
  2153. open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
  2154. "+") + ")\n")
  2155. else:
  2156. Location = ""
  2157. if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
  2158. Warns = str(
  2159. "Amount of warns: *(" + str(
  2160. open(str(chat_id) + "/data/" + str(messageFromID) + ".txt", "r").read()) + "/3)*\n")
  2161. else:
  2162. Warns = ""
  2163. if message == "/check":
  2164. bot.sendMessage(chat_id, "*" + open(
  2165. "data/n" + str(messageFromID) + ".txt").read() + " " + star + "*\n\nCoins: *" + str(
  2166. open("rooms/" + str(messageFromID) + "money.txt",
  2167. "r").read()) + "\n*Wins: *" + str(
  2168. open("rooms/" + str(messageFromID) + "wins.txt",
  2169. "r").read()) + "*\n%s%s%s%s%s%s%s" % (
  2170. Warns,
  2171. Instagram, Reddit, Steam, Location, Soundcloud, Snapchat),
  2172. parse_mode="markdown", disable_web_page_preview=True)
  2173.  
  2174. if "hi bot" in message:
  2175. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  2176. bot.sendMessage(chat_id, "Hi, " + msg['from']['first_name'][:15] + "!")
  2177. else:
  2178. bot.sendMessage(chat_id, "Hi, " + open("data/n" + str(messageFromID) + ".txt").read() + "!")
  2179. if messageType == "private":
  2180. if "/start" in message:
  2181. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
  2182. bot.sendMessage(chat_id, "Hi, " + msg['from']['first_name'][:15] + ". I am @ImmaChatBot, and I am a multi-purpose chat bot! Use /help to see my commands and how to use me. Or, for account help, enter /account.")
  2183. else:
  2184. bot.sendMessage(chat_id, "Hi, " + open("data/n" + str(messageFromID) + ".txt").read() + ". I am @ImmaChatBot, and I am a multi-purpose chat bot! Use /help to see my commands and how to use me. Or, for account help, enter /account.")
  2185. if "/help" in message:
  2186. bot.sendMessage(chat_id, "Commands:\n/roll and /roll2\n/saturate\n/solarize\n/posterize\n/swirl\n/polaroid\n/rblur\n/caption and /captionb for black text\n/kickme\n/def\n/jokes\n/callme\n/addcom and /delcom (add custom commands)\n/blur\n/contour\n/check\n/equalize\n/sharpen\n/invert\n/equalize\n/imagesearch\n\nAdmin Commands:\n/time (for games)\n/promote and /demote\n/ban and /unban\n/kick\n/mute and /unmute\n/byebot (Makes the bot leave the group)\n/photo\n/wel (Toggles welcome message)\n/eb (Toggles 8ball)\n/jt (Toggles jokes)\n/rt (Toggles rolling)\n/gt (Toggles games)\n/reset (Removes warns)\n/end (Ends current game)\n/toggles (Shows whats on and off, some are fillers)\n/time (Set's game time limit)")
  2187. def sticker():
  2188. if 'reply_to_message' in msg:
  2189. try:
  2190. Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
  2191. file_id = msg['reply_to_message']['photo'][2]['file_id']
  2192. filename = str(msg['reply_to_message']['from']['id']) + ".png"
  2193. bot.download_file(file_id, filename)
  2194. im = Image.open(filename)
  2195. im.thumbnail((512, 512))
  2196. im.save("1" + filename)
  2197. bot.sendDocument(chat_id, open("1" + filename, "rb"))
  2198. os.remove(filename)
  2199. os.remove("1" + filename)
  2200. except:
  2201. bot.sendMessage(chat_id, "Error occured")
  2202. else:
  2203. bot.sendMessage(chat_id, "Reply to a photo.")
  2204. if "/stick" in message:
  2205. t = threading.Thread(target=sticker)
  2206. t.start()
  2207. if "/forget" in message:
  2208. if os.path.isfile("data/n" + str(messageFromID) + ".txt") == True:
  2209. bot.sendMessage(chat_id, "_Your name has been forgotten_", parse_mode="markdown")
  2210. os.remove("data/n" + str(messageFromID) + ".txt")
  2211. if "/imagesearch" in message:
  2212. t = threading.Thread(target=imagesearch)
  2213. t.start()
  2214. if messageType == 'private':
  2215. if os.path.isfile("login/" + str(messageFromID) + "LOGGED.txt") == False:
  2216. if "/login" in message:
  2217. contenttype, chattype, chatid = telepot.glance(msg)
  2218. keyboard = InlineKeyboardMarkup(inline_keyboard=[[InlineKeyboardButton(text="Create Account", callback_data='create_')],
  2219. [InlineKeyboardButton(text="Cancel", callback_data='cancel_')]])
  2220. edited = telepot.message_identifier(bot.sendMessage(chat_id, 'Enter your username:', reply_markup=keyboard))
  2221. if os.path.isfile(str(messageFromID) + "login.txt") == False:
  2222. open(str(messageFromID) + "login.txt", "w").write("username")
  2223. elif "/account" in message:
  2224. bot.sendMessage(chat_id, "Hmm.. looks like you're not logged in. Type /login to login, or /create to create an account!")
  2225. elif "/create" in message:
  2226. bot.sendMessage(chat_id, "Alright, what would you like your username to be? (5-18 characters)")
  2227. open(str(messageFromID) + "login.txt", "w").write("createusername")
  2228. open(str(messageFromID) + "data.txt", "w").write(str(messageFromID))
  2229. elif os.path.isfile(str(messageFromID) + "login.txt") == True:
  2230. if open(str(messageFromID) + "login.txt", "r").read() == "username":
  2231. if os.path.isfile("login/" + str(msg['text']) + "login.txt") == False:
  2232. if "/cancel" in message:
  2233. os.remove(str(messageFromID) + "login.txt")
  2234. bot.sendMessage(chat_id, "All operations have been canceled.")
  2235. elif '/login' in message:
  2236. ()
  2237. else:
  2238. bot.sendMessage(chat_id, "This username is not in my database. Try again.")
  2239. elif os.path.isfile('login/' + str(msg['text']) + 'AUTH.txt'):
  2240. open('login/request' + str(msg['text']) + '.txt', 'w').write(str(messageFromID) + '\n' + str(msg['from']['first_name']))
  2241. bot.sendMessage(str(open('login/' + str(msg['text']) + 'AUTH.txt').read()), 'The user, ' + str(open('login/request' + str(msg['text']) + '.txt').read().splitlines()[1] + ', has requested to login. /accept or /decline?'))
  2242. open('login/requesttype.txt', 'w').write('logged')
  2243. bot.sendMessage(chat_id, 'This account has 2-Factor Auth activated. A message has been sent to the account owner. If it is you, go on the account and click /accept.')
  2244. else:
  2245. open(str(messageFromID) + "usernameinput.txt", "w").write(str(msg['text']).replace("[", "").replace("'", "").replace("]", ""))
  2246. open(str(messageFromID) + "login.txt", "w").write("password")
  2247. bot.sendMessage(chat_id, "Enter your password:")
  2248. elif "createusername" in open(str(messageFromID) + "login.txt", "r").read():
  2249. if str(messageFromID) in open(str(messageFromID) + "data.txt", "r").read():
  2250. if os.path.isfile("login/" + str(msg['text']) + "login.txt") == False:
  2251. if "/cancel" in message:
  2252. os.remove(str(messageFromID) + "login.txt")
  2253. bot.sendMessage(chat_id, "All operations have been canceled.")
  2254. else:
  2255. if " " in msg['text'].lower():
  2256. bot.sendMessage(chat_id,
  2257. "You can not have special characters in your username. Like a space..")
  2258. else:
  2259. if len(msg['text'].lower()) > 18:
  2260. bot.sendMessage(chat_id, "That username is too long. Please try a shorter one.")
  2261. elif len(msg['text'].lower()) < 5:
  2262. bot.sendMessage(chat_id,
  2263. "That username is too short. Please try to put a little more.")
  2264. else:
  2265. open("login/" + str(msg['text']) + "login.txt", "w").write(str(""))
  2266. open("login/temp" + str(messageFromID) + ".txt", "w").write(
  2267. str(msg['text'].lower()))
  2268. open(str(messageFromID) + "login.txt", "w").write("createpassword")
  2269. bot.sendMessage(chat_id,
  2270. "What would you like your password to be? (5-18 characters):")
  2271. else:
  2272. bot.sendMessage(chat_id, "That username is already taken, please try again.")
  2273. elif "createpassword" in open(str(messageFromID) + "login.txt", "r").read():
  2274. if " " in msg['text'].lower():
  2275. bot.sendMessage(chat_id,
  2276. "You can not have special characters in your password. Like a space..")
  2277. else:
  2278. if len(msg['text'].lower()) > 18:
  2279. bot.sendMessage(chat_id, "That password is too long. Please try a shorter one.")
  2280. elif len(msg['text'].lower()) < 5:
  2281. bot.sendMessage(chat_id, "That password is too short. Please try to put a little more.")
  2282. elif "/cancel" in message:
  2283. os.remove(str(messageFromID) + "login.txt")
  2284. bot.sendMessage(chat_id, "All operations have been canceled. Account was not made.")
  2285. os.remove('login/temp' + str(messageFromID) + ".txt")
  2286. else:
  2287. open(str(messageFromID) + "login.txt", "w").write("saveusername")
  2288. bot.sendMessage(chat_id, "Account created! Type /login to login.")
  2289. open("login/" + open("login/temp" + str(messageFromID) + ".txt",
  2290. "r").read() + "login.txt", "w").write(
  2291. str(msg['text']))
  2292. os.remove(str(messageFromID) + "login.txt")
  2293. os.remove('login/temp' + str(messageFromID) + ".txt")
  2294. elif "password" in open(str(messageFromID) + "login.txt", "r").read():
  2295. open("login/" + str(
  2296. open(str(messageFromID) + "usernameinput.txt", "r").read()) + "login.txt", "r").read()
  2297. if str(msg['text']) == open("login/" + str(
  2298. open(str(messageFromID) + "usernameinput.txt", "r").read()) + "login.txt",
  2299. "r").read():
  2300. os.remove(str(messageFromID) + "login.txt")
  2301. open("login/" + str(messageFromID) + "LOGGED.txt", "w").write(
  2302. str(open(str(messageFromID) + "usernameinput.txt", "r").read()))
  2303. if os.path.isfile('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt') == False:
  2304. open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt', 'w').write('1')
  2305. else:
  2306. aadd = int(str(open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) + 1
  2307.  
  2308. open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
  2309. bot.sendMessage(chat_id, "You are now logged into " + str(open("login/" + str(messageFromID) + "LOGGED.txt").read()) + "!\nType /account to get started.")
  2310. elif "/cancel" in message:
  2311. os.remove(str(messageFromID) + "login.txt")
  2312. bot.sendMessage(chat_id, "All operations have been canceled.")
  2313. os.remove(str(messageFromID) + "login.txt")
  2314. else:
  2315. bot.sendMessage(chat_id, "Incorrect password. Try again.")
  2316. elif os.path.isfile(str(messageFromID) + "usernameinput.txt") == True:
  2317. if os.path.isfile(str(
  2318. open(str(messageFromID) + "usernameinput.txt", "r").read()) + "login.txt") == True:
  2319. if open(str(open(str(messageFromID) + "usernameinput.txt", "r").read()) + "login.txt"):
  2320. open(str(messageFromID) + "login.txt", "w").write("password")
  2321. elif "saveusername" in open(str(messageFromID) + "login.txt", "r").read():
  2322. if str(messageFromID) in open(str(messageFromID) + "data.txt", "r").read():
  2323. if os.path.isfile("login/temp" + str(messageFromID) + ".txt") == True:
  2324. open("login/" + open("login/temp" + str(messageFromID) + ".txt",
  2325. "r").read() + "login.txt", "w").write(str(msg['text']))
  2326. os.remove(str(messageFromID) + "login.txt")
  2327. else:
  2328. if os.path.isfile('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt").read()) + 'login.txt') == False:
  2329. bot.sendMessage(chat_id, 'You have been signed out. This account has been deleted.')
  2330. os.remove("login/" + str(messageFromID) + 'LOGGED.txt')
  2331. else:
  2332. if os.path.isfile('login/deactivate' + str(messageFromID) + '.txt') == False:
  2333. if "/login" in message:
  2334. bot.sendMessage(chat_id, "You are currently signed into " + str(open("login/" + str(messageFromID) + "LOGGED.txt").read()) + ". To logout, type /logout")
  2335. elif os.path.isfile(str(msg['from']['id']) + 'login.txt') == True:
  2336. if "changepassword" in open(str(messageFromID) + "login.txt", "r").read():
  2337. if str(msg['text']) == open("login/" + str(
  2338. open("login/" + str(messageFromID) + "LOGGED.txt", "r").read()) + "login.txt",
  2339. "r").read():
  2340. bot.sendMessage(chat_id, 'Enter your new password:')
  2341. open(str(msg['from']['id']) + 'login.txt', 'w').write('changing')
  2342. else:
  2343. bot.sendMessage(chat_id, 'That password is incorrect, try again.')
  2344. elif 'changing' in open(str(messageFromID) + 'login.txt').read():
  2345. open('login/' + str(open("login/" + str(messageFromID) + 'LOGGED.txt').read()) + 'login.txt' , 'w').write(str(msg['text']))
  2346. bot.sendMessage(chat_id, 'Password changed!')
  2347. os.remove(str(msg['from']['id']) + 'login.txt')
  2348. elif "/create" in message:
  2349. bot.sendMessage(chat_id, "You are currently signed into " + str(open("login/" + str(messageFromID) + "LOGGED.txt").read()) + ". To logout, type /logout")
  2350. elif "/settings" in message:
  2351. bot.sendMessage(chat_id, "Settings:\n\n/2auth - Toggles 2-Factor Auth on your account.\n/logout - Logs out of current account.\n/sync - Used to sync data.\n/deactivate - deletes the account you're logged into.")
  2352. elif "/account" in message:
  2353. if os.path.isfile('login/' + str(
  2354. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt') == True:
  2355. auth = 'Activated'
  2356. else:
  2357. auth = 'Deactivated'
  2358. keyboard = InlineKeyboardMarkup(
  2359. inline_keyboard=[[InlineKeyboardButton(text="Change Password", callback_data='changepassword_')],
  2360. [InlineKeyboardButton(text="Logout", callback_data='logout_')]])
  2361. edited = telepot.message_identifier(
  2362. bot.sendMessage(chat_id, '┌*Username*: ' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + '\n├*Password*: ' + '••••••••\n├*2-Auth*: ' + auth + '\n└*# of sessions*: ' + str(open('login/' + str(
  2363. open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read()), parse_mode='markdown', reply_markup=keyboard))
  2364. #elif "/2auth" in message:
  2365. # bot.sendMessage(chat_id, "2-Auth has been activated.")
  2366. # #open('login/' + str(open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt', 'r').read().splitlines()[2]) + 'AUTH.txt', 'w').write()
  2367. # open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt', 'w').write(str(messageFromID))
  2368. elif "/2auth" in message:
  2369. if os.path.isfile('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt') == True:
  2370. os.remove('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt')
  2371. bot.sendMessage(chat_id, "2-Factor Authentication has been disabled.")
  2372. else:
  2373. open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt',
  2374. 'w').write(str(messageFromID))
  2375. bot.sendMessage(chat_id, "2-Factor Authentication has been enabled.")
  2376. elif "/deactivate" in msg['text'].lower():
  2377. if os.path.isfile('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt') == True:
  2378. #open('login/request' + str(msg['text']) + '.txt', 'w').write(str(messageFromID) + '\n' + str(msg['from']['first_name']))
  2379. open('login/request' + str(messageFromID) + '.txt', 'w').write(str(messageFromID))
  2380. bot.sendMessage(str(open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt').read()), 'The user, ' + str(open('login/request' + str(messageFromID) + '.txt').read().splitlines()[0] + ', has requested to deactivate this account. /accept or /decline'))
  2381. open('login/requesttype.txt', 'w').write('deactivate')
  2382. bot.sendMessage(chat_id, "To deactivate, click /accept on host account. If you don't have access to this account, contact @spoon")
  2383. else:
  2384. bot.sendMessage(chat_id, "Enter password to deactivate:")
  2385. open('login/deactivate' + str(messageFromID) + '.txt', 'w').write('deactivate')
  2386. elif "/accept" in message:
  2387. if 'logged' in open('login/requesttype.txt').read():
  2388. open('login/request' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + '.txt').read()
  2389. open('login/' + str(open('login/request' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + '.txt').read().splitlines()[0]) + 'LOGGED.txt', 'w').write(str(open("login/" + str(messageFromID) + "LOGGED.txt").read()))
  2390. bot.sendMessage(str(open('login/request' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + '.txt').read().splitlines()[0]), 'You were accepted. You are now logged in!')
  2391. os.remove('login/request' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + '.txt')
  2392. aadd = int(str(open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) + 1
  2393. open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
  2394. os.remove('login/requesttype.txt')
  2395. else:
  2396. if os.path.isfile('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt'):
  2397. os.remove('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt')
  2398. if os.path.isfile('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt'):
  2399. os.remove('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt')
  2400. if os.path.isfile('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'login.txt'):
  2401. os.remove('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'login.txt')
  2402. os.remove('login/' + str(messageFromID) + 'LOGGED.txt')
  2403. os.remove('login/request' + str(messageFromID) + '.txt')
  2404. os.remove('login/requesttype.txt')
  2405. bot.sendMessage(chat_id, 'This account has been deactivated. You have been logged out.')
  2406. elif "/logout" in message:
  2407. if os.path.isfile('login/' + str(
  2408. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt'):
  2409. if str(messageFromID) in open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AUTH.txt').read():
  2410. bot.sendMessage(chat_id, "You have logged out of " + str(open("login/" + str(
  2411. messageFromID) + "LOGGED.txt").read()) + '. 2-Auth has been deactivated.')
  2412. if '1' in open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read():
  2413. os.remove('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt')
  2414. os.remove("login/" + str(open("login/" + str(messageFromID) + "LOGGED.txt").read()) + "AUTH.txt")
  2415. os.remove("login/" + str(messageFromID) + "LOGGED.txt")
  2416. else:
  2417. aadd = int(str(open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) - 1
  2418. open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
  2419. else:
  2420. if '1' in open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt",
  2421. 'r').read()) + 'AMOUNT.txt').read():
  2422. os.remove('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt",
  2423. 'r').read()) + 'AMOUNT.txt')
  2424. else:
  2425. aadd = int(str(open('login/' + str(
  2426. open("login/" + str(messageFromID) + "LOGGED.txt",
  2427. 'r').read()) + 'AMOUNT.txt').read())) - 1
  2428. open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt",
  2429. 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
  2430. bot.sendMessage(chat_id, "You have logged out of " + str(
  2431. open("login/" + str(messageFromID) + "LOGGED.txt").read()) + '.')
  2432. os.remove("login/" + str(messageFromID) + "LOGGED.txt")
  2433. else:
  2434. bot.sendMessage(chat_id, "You have logged out of " + str(open("login/" + str(messageFromID) + "LOGGED.txt").read()) + '.')
  2435. if '1' in open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read():
  2436. os.remove('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt')
  2437. os.remove("login/" + str(messageFromID) + "LOGGED.txt")
  2438. else:
  2439. aadd = int(str(open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) - 1
  2440. open('login/' + str(open("login/" + str(messageFromID) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
  2441.  
  2442. elif "/sync" in message:
  2443. bot.sendMessage(chat_id, "Would you like to /save or /load?\n(WARNING: Saving will replace old saved data, and loading will replace your current wins and money.)")
  2444. open("login/" + str(messageFromID) + "syncing.txt", "w").write("selection")
  2445. elif os.path.isfile("login/" + str(messageFromID) + "syncing.txt") == True:
  2446. if 'selection' in open("login/" + str(messageFromID) + "syncing.txt", "r").read():
  2447. if '/save' in message:
  2448. bot.sendMessage(chat_id, "Saving all data...")
  2449. bot.sendMessage(chat_id, "Saved!")
  2450. wins = str(open('rooms/' + str(messageFromID) + "wins.txt").read())
  2451. money = str(open('rooms/' + str(messageFromID) + "money.txt").read())
  2452. wrote = str(messageFromID)
  2453. open('login/' + str(open('login/' + str(messageFromID) + "LOGGED.txt", 'r').read()) + "DATA.txt", 'w').write(wins + '\n' + money + '\n' + wrote)
  2454. os.remove("login/" + str(messageFromID) + "syncing.txt")
  2455. elif '/load' in message:
  2456. bot.sendMessage(chat_id, "Getting saved data...")
  2457. bot.sendMessage(chat_id, "Loaded!")
  2458. open('rooms/' + str(messageFromID) + "wins.txt", 'w').write(str(open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt', 'r').read().splitlines()[0]))
  2459. open('rooms/' + str(messageFromID) + "money.txt", 'w').write(str(open(
  2460. 'login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt',
  2461. 'r').read().splitlines()[1]))
  2462. open('rooms/' + str(messageFromID) + "money.txt", 'w').write(str(open(
  2463. 'login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt',
  2464. 'r').read().splitlines()[1]))
  2465. open('rooms/' + str(open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt', 'r').read().splitlines()[2]) + 'wins.txt', 'w').write('0')
  2466. open('rooms/' + str(open('login/' + str(open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt', 'r').read().splitlines()[2]) + 'money.txt', 'w').write('0')
  2467. os.remove("login/" + str(messageFromID) + "syncing.txt")
  2468. if "/cancel" in message:
  2469. os.remove(str(messageFromID) + "login.txt")
  2470. bot.sendMessage(chat_id, "All operations have been canceled.")
  2471. if "/test" in message:
  2472. dir_list = next(os.walk('.'))[1]
  2473. if str(dir_list[1]).startswith('-'):
  2474. print(dir_list[1])
  2475. elif 'deactivate' in open('login/deactivate' + str(messageFromID) + '.txt').read():
  2476. if str(msg['text']) == open("login/" + str(
  2477. open("login/" + str(messageFromID) + "LOGGED.txt", "r").read()) + "login.txt",
  2478. "r").read():
  2479. if os.path.isfile('login/' + str(
  2480. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt') == True:
  2481. os.remove('login/' + str(
  2482. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'DATA.txt')
  2483. if os.path.isfile('login/' + str(
  2484. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt') == True:
  2485. os.remove('login/' + str(
  2486. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AUTH.txt')
  2487. if os.path.isfile('login/' + str(
  2488. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'login.txt') == True:
  2489. os.remove('login/' + str(
  2490. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'login.txt')
  2491.  
  2492. os.remove('login/' + str(
  2493. open('login/' + str(messageFromID) + 'LOGGED.txt').read()) + 'AMOUNT.txt')
  2494. os.remove('login/' + str(messageFromID) + 'LOGGED.txt')
  2495. bot.sendMessage(chat_id, 'This account has been deactivated. You have been logged out.')
  2496. os.remove('login/deactivate' + str(messageFromID) + '.txt')
  2497. else:
  2498. bot.sendMessage(chat_id, 'Incorrect password. Retry later.')
  2499. os.remove('login/deactivate' + str(messageFromID) + '.txt')
  2500. if messageType != 'private':
  2501. if "True" in open(str(chat_id) + "/data/8ball.txt", "r"):
  2502. if "/magic8 " in message:
  2503. bot.sendMessage(chat_id, (random.choice(eightball)),
  2504. reply_to_message_id=msg['message_id'])
  2505. if message == "/magic8":
  2506. bot.sendMessage(chat_id, '/magic8 <question>')
  2507. if message == '/m8':
  2508. bot.sendMessage(chat_id, "/m8 <question>")
  2509. if message == '/m8@ImmaChatBot':
  2510. bot.sendMessage(chat_id, "/m8 <question>")
  2511. if "/m8 " in message:
  2512. bot.sendMessage(chat_id, (random.choice(eightball)),
  2513. reply_to_message_id=msg['message_id'])
  2514. if '/remove' in message:
  2515. reply_markup = telegram.ReplyKeyboardRemove()
  2516. Bot.sendMessage(chat_id=chat_id, text="removed.", reply_markup=reply_markup)
  2517. global edited
  2518. def on_callback_query(msg):
  2519. query_id, from_id, query_data = telepot.glance(msg, flavor='callback_query')
  2520. if query_data == 'create_':
  2521. keyboard = InlineKeyboardMarkup(
  2522. inline_keyboard=[[InlineKeyboardButton(text="Cancel", callback_data='cancel_')]])
  2523. bot.editMessageText(edited, "Alright, what would you like your username to be? (5-18 characters)", reply_markup=keyboard)
  2524. open(str(msg['from']['id']) + "login.txt", "w").write("createusername")
  2525. open(str(msg['from']['id']) + "data.txt", "w").write(str(msg['from']['id']))
  2526. elif query_data == 'cancel_':
  2527. os.remove(str(from_id) + "login.txt")
  2528. bot.editMessageText(edited, "All operations have been canceled.")
  2529. elif query_data == 'changepassword_':
  2530. keyboard = InlineKeyboardMarkup(
  2531. inline_keyboard=[[InlineKeyboardButton(text="Back", callback_data='Back_')]])
  2532. open(str(msg['from']['id']) + "login.txt", "w").write("changepassword")
  2533. bot.editMessageText(edited, "Enter your old password:", reply_markup=keyboard)
  2534. elif query_data == 'logout_':
  2535. if os.path.isfile('login/' + str(
  2536. open('login/' + str(from_id) + 'LOGGED.txt').read()) + 'AUTH.txt'):
  2537. if str(from_id) in open('login/' + str(
  2538. open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AUTH.txt').read():
  2539. bot.editMessageText(edited, "You have logged out of " + str(open("login/" + str(
  2540. from_id) + "LOGGED.txt").read()) + '. 2-Auth has been deactivated.')
  2541. if '1' in open('login/' + str(
  2542. open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read():
  2543. os.remove(
  2544. 'login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt')
  2545. os.remove("login/" + str(open("login/" + str(from_id) + "LOGGED.txt").read()) + "AUTH.txt")
  2546. os.remove("login/" + str(from_id) + "LOGGED.txt")
  2547. else:
  2548. aadd = int(str(open('login/' + str(
  2549. open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) - 1
  2550. open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt',
  2551. 'w').write(str(aadd))
  2552. else:
  2553. if '1' in open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt",
  2554. 'r').read()) + 'AMOUNT.txt').read():
  2555. os.remove('login/' + str(open("login/" + str(from_id) + "LOGGED.txt",
  2556. 'r').read()) + 'AMOUNT.txt')
  2557. else:
  2558. aadd = int(str(open('login/' + str(
  2559. open("login/" + str(from_id) + "LOGGED.txt",
  2560. 'r').read()) + 'AMOUNT.txt').read())) - 1
  2561. open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt",
  2562. 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
  2563. bot.editMessageText(edited, "You have logged out of " + str(
  2564. open("login/" + str(from_id) + "LOGGED.txt").read()) + '.')
  2565. os.remove("login/" + str(from_id) + "LOGGED.txt")
  2566. else:
  2567. bot.editMessageText(edited, "You have logged out of " + str(
  2568. open("login/" + str(from_id) + "LOGGED.txt").read()) + '.')
  2569. if '1' in open('login/' + str(
  2570. open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read():
  2571. os.remove('login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt')
  2572. os.remove("login/" + str(from_id) + "LOGGED.txt")
  2573. else:
  2574. aadd = int(str(open('login/' + str(
  2575. open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) - 1
  2576. open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt',
  2577. 'w').write(str(aadd))
  2578. else:
  2579. bot.editMessageText(edited, "please..",
  2580. parse_mode="markdown")
  2581. bot = telepot.Bot(no lol)
  2582. Bot = telegram.Bot(no lol)
  2583. #bot.message_loop(handle)
  2584. bot.message_loop({'chat': handle,
  2585. 'callback_query': on_callback_query})
  2586. while 1:
  2587. time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement