Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telepot
- import random
- from random import shuffle
- import urbandict
- from collections import OrderedDict
- import string
- import cv2
- import pytz
- from datetime import datetime
- from mmap import mmap
- import glob
- from googletrans import Translator
- import requests
- import numpy as np
- # from model import Deeplabv3
- import itertools
- from random_words import RandomWords
- from collections import Counter
- import telegram
- import urllib
- import urllib3
- import datetime
- import threading
- import json
- import linecache
- #from weather import Weather, Unit
- import subprocess
- import io
- from matplotlib import pyplot as pltz
- import sys
- import re
- from threading import Thread
- import time
- from telepot.namedtuple import ReplyKeyboardMarkup, ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton, \
- KeyboardButton
- import PIL
- from PIL import Image, ImageFont, ImageDraw, ImageOps, ImageFilter
- from PIL import ImageEnhance
- import datetime
- import os
- from gtts import gTTS
- from timezonefinder import TimezoneFinder
- from geopy.geocoders import GoogleV3
- import random
- import datetime
- from geopy import geocoders
- import timezonefinder, pytz
- from pytz import timezone
- tf = TimezoneFinder()
- translator = Translator()
- if not os.path.exists("feedback/"):
- os.makedirs("feedback/")
- botID = str(open('token.dat', 'r').read()).split(':')[0]
- print('\u2022')
- startSpam = False
- safetyNet = False
- def handle(msg):
- print('1')
- stickerExecute = True
- global safetyNet
- global edited
- global startSpam
- global USER
- global message
- global meProfileUser
- global meProfileName
- #FILES AND DIRECTORIES
- if 'from' in msg:
- messageFromID = msg['from']['id']
- else:
- messageFromID = 'None'
- if 'type' in msg:
- messageType = msg['chat']['type']
- else:
- messageType = "None"
- try:
- messageType = msg['chat']['type']
- except:
- messagType = 'None'
- if messageType != 'private':
- isPrivateMessage = False
- toSend = True
- isGroup = True
- else:
- isPrivateMessage = True
- toSend = False
- isGroup = False
- if 'chat' in msg:
- if str(msg['chat']['id']) == '-1001347177423':
- if 'True' in open('data/debug.txt', 'r').read():
- chat_id = str(-1001310035457)
- else:
- chat_id = str(msg['chat']['id'])
- else:
- chat_id = str(msg['chat']['id'])
- else:
- chat_id = "None"
- if 'data' in msg:
- global warnd
- isInlineResponse = True
- messageInlineData = msg['data']
- print(messageInlineData)
- else:
- isInlineResponse = False
- messageInlineData = 'None'
- global warnd
- global promoted
- if 'message_id' in msg:
- messageID = str(msg['message_id'])
- else:
- messageID = 'None'
- if messageType != 'private':
- if not os.path.exists(str(chat_id)):
- os.makedirs(str(chat_id))
- os.makedirs(str(chat_id) + "/messages/")
- os.makedirs(str(chat_id) + "/rooms/")
- os.makedirs(str(chat_id) + "/data/")
- if not os.path.exists("data/"):
- os.makedirs("data/")
- if not os.path.exists("login/"):
- os.makedirs("login/")
- if not os.path.exists("rooms/"):
- os.makedirs("rooms/")
- if os.path.isfile("data/usernames.txt") == False:
- open("data/usernames.txt", "w").write("admin\nspoon\n")
- if os.path.isfile("data/listofgroups.data") == False:
- open("data/listofgroups.data", "w").write("")
- if os.path.isfile("data/listofusers.data") == False:
- open("data/listofusers.data", "w").write("")
- if os.path.isfile(str(chat_id) + "/data/adminlist.data") == False:
- open(str(chat_id) + "/data/adminlist.data", "w").write("")
- if os.path.isfile(str(chat_id) + "/data/numberone.txt") == False:
- open(str(chat_id) + "/data/numberone.txt", "w").write("ImmaChatBot\nImmaChatBot\n0")
- if os.path.isfile(str(chat_id) + "/data/numbertwo.txt") == False:
- open(str(chat_id) + "/data/numbertwo.txt", "w").write("ImmaChatBot2\nImmaChatBot2\n0")
- if os.path.isfile(str(chat_id) + "/data/numberthree.txt") == False:
- open(str(chat_id) + "/data/numberthree.txt", "w").write("ImmaChatBot3\nImmaChatBot3\n0")
- if os.path.isfile(str(chat_id) + "/data/tts.txt") == False:
- open(str(chat_id) + "/data/tts.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/imagecolor.txt") == False:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("black")
- if os.path.isfile(str(chat_id) + "/data/compref.txt") == False:
- open(str(chat_id) + "/data/compref.txt", "w").write("/")
- if os.path.isfile(str(chat_id) + "/data/textcolor.txt") == False:
- open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
- if os.path.isfile(str(chat_id) + "/data/gamelimit.txt") == False:
- open(str(chat_id) + "/data/gamelimit.txt", "w").write("30")
- if os.path.isfile("data/debug.txt") == False:
- open("data/debug.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/greet.txt") == False:
- open(str(chat_id) + "/data/greet.txt", "w").write("Text")
- if os.path.isfile(str(chat_id) + "/data/games.txt") == False:
- open(str(chat_id) + "/data/games.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/word.txt") == False:
- open(str(chat_id) + "/data/word.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/admin.txt") == False:
- open(str(chat_id) + "/data/admin.txt", "w").write
- if os.path.isfile(str(chat_id) + "/data/jokes.txt") == False:
- open(str(chat_id) + "/data/jokes.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/limit.txt") == False:
- open(str(chat_id) + "/data/limit.txt", "w").write("750")
- if os.path.isfile(str(chat_id) + "/data/8ball.txt") == False:
- open(str(chat_id) + "/data/8ball.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/arabic.txt") == False:
- open(str(chat_id) + "/data/arabic.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/leaderboard.txt") == False:
- open(str(chat_id) + "/data/leaderboard.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/scramble.txt") == False:
- open(str(chat_id) + "/data/scramble.txt", "w").write('False')
- if os.path.isfile(
- str(chat_id) + "/data/type.txt") == False:
- open(
- str(chat_id) + "/data/type.txt", "w").write('False')
- if os.path.isfile(str(chat_id) + "/data/spam.txt") == False:
- open(str(chat_id) + "/data/spam.txt", "w").write('True')
- if os.path.isfile(str(chat_id) + "/data/roll.txt") == False:
- open(str(chat_id) + "/data/roll.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/blacklisted.txt") == False:
- open(str(chat_id) + "/data/blacklisted.txt", "w").write("")
- if os.path.isfile(str(chat_id) + "/data/link.txt") == False:
- open(str(chat_id) + "/data/link.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/temp.txt") == False:
- open(str(chat_id) + "/data/temp.txt", "w")
- if os.path.isfile(str(chat_id) + "/data/lock.txt") == False:
- open(str(chat_id) + "/data/lock.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/game.txt") == False:
- open(str(chat_id) + "/data/game.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/state.txt") == False:
- open(str(chat_id) + "/data/state.txt", "w").write('False')
- if os.path.isfile(str(chat_id) + "/data/pong.txt") == False:
- open(str(chat_id) + "/data/pong.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/mm.txt") == False:
- open(str(chat_id) + "/data/mm.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/games.txt") == False:
- open(str(chat_id) + "/data/games.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/antibot.txt") == False:
- open(str(chat_id) + "/data/antibot.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/urban.txt") == False:
- open(str(chat_id) + "/data/urban.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/flip.txt") == False:
- open(str(chat_id) + "/data/flip.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/blacklist.txt") == False:
- open(str(chat_id) + "/data/blacklist.txt", "w")
- if os.path.isfile(str(chat_id) + "/data/blacklistusername.txt") == False:
- open(str(chat_id) + "/data/blacklistusername.txt", "w")
- if os.path.isfile(str(chat_id) + "/data/wel.txt") == False:
- open(str(chat_id) + "/data/wel.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/photo.txt") == False:
- open(str(chat_id) + "/data/photo.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/admin.txt") == False:
- open(str(chat_id) + "/data/admin.txt", "w")
- if os.path.isfile(str(chat_id) + "/data/remind.txt") == False:
- open(str(chat_id) + "/data/remind.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/data/tts.txt") == False:
- open(str(chat_id) + "/data/tts.txt", "w").write("False")
- if os.path.isfile(str(chat_id) + "/wel.txt") == False:
- if messageType != 'private':
- open(str(chat_id) + "/wel.txt", "w").write("True")
- if os.path.isfile(str("data/locked" + str(messageFromID) + ".txt")) == False:
- open(str("data/locked" + str(messageFromID) + ".txt"), "w").write("False")
- #DEFINE MESSAGES
- if os.path.isfile(str(chat_id) + "/data/photo.txt") == False:
- open(str(chat_id) + "/data/photo.txt", "w").write("True")
- if os.path.isfile(str(chat_id) + "/data/8ball.txt") == False:
- open(str(chat_id) + "/data/8ball.txt", "w").write("True")
- if 'caption' in msg:
- caption = str(msg['caption'])
- else:
- caption = None
- def newCap():
- if messageType != 'private':
- if os.path.isfile("rooms/" + str(messageFromID) + "wins.txt") == False:
- open("rooms/" + str(messageFromID) + "wins.txt", "w").write("0")
- if os.path.isfile("rooms/" + str(messageFromID) + "money.txt") == False:
- open("rooms/" + str(messageFromID) + "money.txt", "w").write("0")
- if os.path.isfile(str(chat_id) + "/messagecount.txt") == False:
- open(str(chat_id) + "/messagecount.txt", "w").write("1")
- else:
- try:
- minus = int(str(open(str(chat_id) + "/messagecount.txt", "r+").readlines()).replace("[", "").replace("'", "").replace("]", "")) + 1
- open(str(chat_id) + "/messagecount.txt", "w").write(str(minus))
- except:
- open(str(chat_id) + "/messagecount.txt", "w").write('1')
- if 'username' in msg['from']:
- USER = "\n[" + str(msg['from']['username']) + "](t.me/" + str(msg['from']['username']) + ")"
- else:
- USER = "\n" + str(msg['from']['first_name'])
- with open(str(chat_id) + "/data/numberone.txt", "r") as one:
- for _ in range(3):
- numberone = one.readline()
- with open(str(chat_id) + "/data/numbertwo.txt", "r") as two:
- for _ in range(3):
- numbertwo = two.readline()
- with open(str(chat_id) + "/data/numberthree.txt", "r") as three:
- for _ in range(3):
- numberthree = three.readline()
- if os.path.isfile(
- str(chat_id) +
- '/messages/' + str(messageFromID) + ".txt") == False:
- open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "w").write("1")
- if int(str(open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r").read())) > int(str(numberone)):
- open(str(chat_id) + "/data/numberone.txt", "w").write(str(msg['from']['id']) + USER + "\n" + str(open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r").read()))
- if int(str(open("rooms/" + str(messageFromID) + "money.txt", "r").read())) > int(str(numbertwo)):
- open(str(chat_id) + "/data/numbertwo.txt", "w").write(str(msg['from']['id']) + USER + "\n" + str(open(
- "rooms/" + str(messageFromID) + "money.txt", "r").read()))
- if int(str(open(
- "rooms/" + str(messageFromID) + "wins.txt", "r").read())) > int(str(numberthree)):
- open(str(chat_id) + "/data/numberthree.txt", "w").write(str(msg['from']['id']) + USER + "\n" + str(open("rooms/" + str(messageFromID) + "wins.txt", "r").read()))
- else:
- with open(str(chat_id) + "/data/numberone.txt", "r") as one:
- for _ in range(3):
- numberone = one.readline()
- with open(str(chat_id) + "/data/numbertwo.txt", "r") as two:
- for _ in range(3):
- numbertwo = two.readline()
- with open(str(chat_id) + "/data/numberthree.txt", "r") as three:
- for _ in range(3):
- numberthree = three.readline()
- try:
- minus = int(
- str(open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r+").readlines()).replace("[", "").replace(
- "'", "").replace("]", "")) + 1
- open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "w").write(str(minus))
- except:
- open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "w").write('1')
- try:
- if int(str(open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r").read())) > int(str(numberone)):
- open(str(chat_id) + "/data/numberone.txt", "w").write(str(msg['from']['id']) + USER + "\n" + str(open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r").read()))
- except:
- open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "w").write('2')
- if int(str(open("rooms/" + str(messageFromID) + "money.txt", "r").read())) > int(str(numbertwo)):
- open(str(chat_id) + "/data/numbertwo.txt", "w").write(str(msg['from']['id']) + USER + "\n" + str(open(
- "rooms/" + str(messageFromID) + "money.txt", "r").read()))
- if int(str(open(
- "rooms/" + str(messageFromID) + "wins.txt", "r").read())) > int(str(numberthree)):
- open(str(chat_id) + "/data/numberthree.txt", "w").write(str(msg['from']['id']) + USER + "\n" + str(open("rooms/" + str(messageFromID) + "wins.txt", "r").read()))
- if isPrivateMessage == False:
- print(msg['chat']['title'], ', ', msg['from']['first_name'], ':\n', msg['text'])
- else:
- print('Private Message, ', msg['from']['first_name'], ':\n', msg['text'])
- if 'text' in msg:
- t = threading.Thread(target=newCap)
- t.start()
- message = msg['text'].lower()
- else:
- if 'caption' in msg:
- message = msg['caption'].lower()
- else:
- message = ''
- if '/debug' in message:
- if str(msg['from']['id']) == str('374986841'):
- if '353129131' in str(open('token.dat', 'r').read()):
- if "True" in open("data/debug.txt", "r"):
- open("data/debug.txt", "w").write("False")
- bot.sendMessage(str(-1001347177423), "Debug mode off. I will now reply.")
- else:
- open("data/debug.txt", "w").write("True")
- bot.sendMessage(str(-1001347177423), "Debug mode on. I will no longer reply.")
- def replace_line(file_name, line_num, text):
- lines = open(file_name, 'r').readlines()
- lines[line_num] = text
- out = open(file_name, 'w')
- out.writelines(lines)
- out.close()
- def gettime():
- tf = timezonefinder.TimezoneFinder()
- saidlocation = str(msg['text'])[6:]
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(saidlocation)
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- if timezone_str is None:
- print('Nah')
- else:
- timeZone = pytz.timezone(timezone_str)
- dt = datetime.datetime.utcnow()
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- print(location_time.strftime('It is currently %I:%M %p in ' + saidlocation + '.'))
- bot.sendMessage(chat_id, location_time.strftime('It is currently %I:%M %p in ' + saidlocation.title() + '.'))
- if '/time ' in message:
- t = threading.Thread(target=gettime)
- t.start()
- def getLastLines(path, n):
- # return the las N lines from the file indicated in path
- fp = open(path)
- for i in range(n):
- line = fp.readline()
- if line == '':
- return []
- back = open(path)
- for each in fp:
- back.readline()
- result = []
- for line in back:
- result.append(line[:-1])
- return result
- def spamDetection():
- endTime = datetime.datetime.now() + datetime.timedelta(
- seconds=5)
- while True:
- if datetime.datetime.now() >= endTime:
- os.remove(str(chat_id) + "/messages/" + str(msg['from']['id']) + 'spam.dat')
- os.remove(str(chat_id) + "/messages/" + str(msg['from']['id']) + 'cache.dat')
- break
- if "5" in str(open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "r").read()):
- if "True" in open(str(chat_id) + "/data/spam.txt", "r"):
- os.remove(str(chat_id) + "/messages/" + str(msg['from']['id']) + 'spam.dat')
- bot.restrictChatMember(chat_id, msg['from']['id'], can_send_messages=False,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- print('MUTED USER FOR SPAM')
- bot.sendMessage(chat_id, usersName + " has been muted for spamming. (Use /spam to turn off)", reply_to_message_id=msg['message_id'])
- messageOne = str(open(str(chat_id) + "/messages/" + 'msgid' + str(msg['from']['id']) + ".dat", "r").readlines()[0])
- lastestMessages = getLastLines(str(chat_id) + "/messages/" + 'msgid' + str(msg['from']['id']) + ".dat", 12)
- for line in lastestMessages:
- try:
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=line)
- except:
- pass
- break
- else:
- os.remove(str(chat_id) + "/messages/" + str(msg['from']['id']) + 'spam.dat')
- os.remove(str(chat_id) + "/messages/" + str(msg['from']['id']) + 'cache.dat')
- def getMessage():
- if os.path.isfile(str(chat_id) + '/messages/msgid' + str(msg['from']['id']) + '.dat') == False:
- open(str(chat_id) + '/messages/msgid' + str(msg['from']['id']) + '.dat', 'w').write(
- str(msg['message_id']) + '\n')
- else:
- open(str(chat_id) + '/messages/msgid' + str(msg['from']['id']) + '.dat', 'a+').write(
- str(msg['message_id']) + '\n')
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt", "r").read():
- pass
- else:
- if startSpam == True:
- if 'photo' in msg:
- if 'caption' in msg:
- if msg['caption'] == "":
- pass
- else:
- if os.path.isfile(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat") == False:
- # open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "w").write("1")
- # open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "cache.dat", "w").write(
- # str(msg['message_id']) + '\n')
- # t = threading.Thread(target=spamDetection)
- # t.start()
- pass
- else:
- if '1' in open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "r").read():
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "w").write("2")
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "cache.dat", "a+").write(
- str(msg['message_id']) + '\n')
- elif '2' in open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "r").read():
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "w").write("3")
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "cache.dat", "a+").write(
- str(msg['message_id']) + '\n')
- elif '3' in open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "r").read():
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "w").write("4")
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "cache.dat", "a+").write(
- str(msg['message_id']) + '\n')
- elif '4' in open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "r").read():
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "spam.dat", "w").write("5")
- open(str(chat_id) + "/messages/" + str(msg['from']['id']) + "cache.dat", "a+").write(
- str(msg['message_id']) + '\n')
- if msg:
- if isPrivateMessage == False:
- t = threading.Thread(target=getMessage)
- t.start()
- if isPrivateMessage == True:
- if '/kickme' in msg['text']:
- contents = '*Kick me*\n\nWith this command, you can leave a group with a single command. This only kicks, so you can join back.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/scramble' in msg['text']:
- contents = '*Scramble*\n\nThis is a fun game where you unscramble words with friends, and try to be the first one to win. Depending on how hard the words are, you get a different amount of coins each time. Default time limit is 30 seconds, but this can be changed with /limit.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/unban' in msg['text']:
- contents = '*Unbanning users*\n\nEasily unban users with this command, by replying or "/ban @username."\n\n_/unban @USER\n/unban (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/mute' in msg['text']:
- contents = '*Muting users*\n\nYou can mute users from talking in a group chat. With this, they can still read the chat.\n\n_/mute @USER\n/mute (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/delcom' in msg['text']:
- contents = '*Deleting commands*\n\nThis command is used to delete existing commands. All you have to do is use "/delcom /hug" and thats it.\n\n_/delcom <command name>_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/photo' in msg['text']:
- contents = '*Toggling photo editing*\n\nUse this to turn on and off the photo editing feature.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/voice' in msg['text']:
- contents = '*Toggling text to speech*\n\nThis command toggles the ability to use the text to speech command (/tts)'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/arabic' in msg['text']:
- contents = '*Toggling arabic text*\n\nA lot of times, arabic is used to spam chats, so this helps prevent this. Use /arabic to toggle the auto-delete arabic feature. Whenever anyone send arabic characters, the message will be deleted.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/blacklist' in msg['text']:
- contents = '*Blacklisting phrases*\n\nThis command is used for blacklisting certain phrases. To use this, you use "/blacklist <phrase to be blacklisted" and whenever this is used, the message is deleted and the user is kicked.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/nomedia' in msg['text']:
- contents = '*Restricting media messages*\n\nRestrict a users ablity to send media messages like images, gifs, voice messages, files, or stickers.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/lock' in msg['text']:
- contents = '*Locking your groupchat*\n\nWith this, you can lock and unlock your group chat. Everytime someone tries to join, they get kicked. Use this to toggle on and off.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/gt' in msg['text']:
- contents = '*Games toggle*\n\nTurn games on and off with this command.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/eb' in msg['text']:
- contents = '*Toggle 8ball questions*\n\nTurn /8ball messages on and off.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/antibot' in msg['text']:
- contents = '*Restricting bots from your group*\n\nToggle this to either restrict users from adding bots, or not.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/jt' in msg['text']:
- contents = '*Toggling jokes*\n\nUse this to disable the joke feature (/jokes).'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/roll' in msg['text']:
- if 'help' in msg['text']:
- if 'roll2' in msg['text']:
- contents = '*Rolling two dice*\n\nRoll two dice with this command.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- contents = '*Rolling a single die*\n\nRoll a single die with this command.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- pass
- if '/bw' in msg['text']:
- if 'reply_to_message' in msg:
- contents = '*Making an image black and white*\n\nThis make the selected image black and white.\n\n_/bw (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if 'help' in msg['text']:
- contents = '*Making an image black and white*\n\nThis make the selected image black and white.\n\n_/bw (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- contents = '*Making an image black and white*\n\nThis make the selected image black and white.\n\n_/bw (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/swirl' in msg['text']:
- if 'reply_to_message' in msg:
- contents = '*Swirling an image*\n\nThis make the selected image swirled.\n\n_/swirl (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if 'help' in msg['text']:
- contents = '*Swirling an image*\n\nThis make the selected image swirled.\n\n_/swirl (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- contents = '*Swirling an image*\n\nThis make the selected image swirled.\n\n_/swirl (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/rt' in msg['text']:
- contents = '*Toggling rolling dice*\n\nToggle the /roll and /roll2 feature_.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/pin' in msg['text']:
- contents = '*Pinning messages*\n\nReply to any message to pin it in the group.\n\n_/pin (REPLIED)'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/color' in msg['text']:
- contents = '*Changing welcome message color*\n\nUse this to change the welcome greet pictures color. Use /color <color name>\n\nExample:\n\n/color pink\n\n_User Joined:_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- filename = 'colorexamp.jpg'
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- bot.sendPhoto(chat_id, open(filename, "rb"))
- else:
- if isPrivateMessage == True:
- filename = 'colorexamp.jpg'
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- bot.sendPhoto(chat_id, open(filename, "rb"))
- if '/colour' in msg['text']:
- contents = '*Changing welcome message colour*\n\nUse this to change the welcome greet pictures colour. Use /colour <colour name>\n\nExample:\n\n/colour pink\n\n_User Joined:_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- filename = 'colorexamp.jpg'
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- bot.sendPhoto(chat_id, open(filename, "rb"))
- else:
- if isPrivateMessage == True:
- filename = 'colorexamp.jpg'
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- bot.sendPhoto(chat_id, open(filename, "rb"))
- if '/greet' in msg['text']:
- contents = '*Changing greeting message type*\n\nUse this to toggle between a text welcome message and a picture welcome message. Default is text. Use /wel with photo greeting on, and change the text that says "Welcome" to your choice! Or change the color with /color'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/title' in msg['text']:
- contents = '*Change the title of the group*\n\nUse this command to change the title of your groupchat.\n\n_/title <new title of chat>_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/limit' in msg['text']:
- contents = '*Changing the game time limit*\n\nThis command gives you the ablility to change how long each scramble game lasts. This is in seconds.\n\n_/limit <time in seconds>_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/promote' in msg['text']:
- contents = '*Promoting users in your group*\n\nThis command lets your promote users to be admin of the bot, but not the actually group. What this means is that the user can user commands like /kick or /ban on the bot, but they would not be an actual admin.\n\n_/promote @USER\n/promote (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/warn' in msg['text']:
- contents = '*Warning users*\n\nIf a user did something bad, and you want to give them a few chances, you can warn them. Everyone get 3 warns, then you are kicked. View your warns on /me, reset someones warns with /reset.\n\n_/warn @USER\n/warn (REPLIED)\n/reset @USER\n/warn (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/reset' in msg['text']:
- contents = '*Resetting someones warns*\n\nReset a users warn count.\n\n_/reset @USER\n/reset (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/demote' in msg['text']:
- contents = '*Demoting users in your group*\n\nThis command lets your demotes users and takes their admin away (no group admin).\n\n_/demote @USER\n/demote (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/toggles' in msg['text']:
- contents = '*View your toggles*\n\nView what features are on and off.\n\n' + """Example:\n_Jokes: Off
- Magic 8Ball: On
- Rolling: Off
- Invite Links: On
- Group Lock: Off
- Antibot: On
- Photo edit: On
- Urban Dict: On
- TTS: On_"""
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/unrestrict' in msg['text']:
- contents = '*Unrestricting users*\n\nThis command is used to unrestrict users and giving them all chat permissions (sending messages, photos, gifs, etc)\n\n_/unrestrict @USER\n/unrestrict (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/addcom' in msg['text']:
- contents = "*Adding custom commands*\n\nIf you want a command like /slap, or simply a counter for how many times someone gets banned, you can use this to satisfy your needs. This command allows you to add your own commands and have it respond in a certain way when it hears a phrase. For example, if you wanted a hug command you would make it like this (NOTE: You do not need to use a slash, it can be any phrase):\n\n/addcom /hug::$rn has been hugged by $n!\n\nThe $rn symbolizes the name of the person you are replying to. The $n is the one who sends the message.\n\n*Adding a counter*\n\nTo add a counter, you can do this\n\n/addcom /score::The current score is $c!\n\nThe $c is updated by one everytime the command is used."
- if 'Universal commands' in msg['text']:
- pass
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- bot.sendMessage(chat_id, '\n\n*More customs:*\n$rn - Replied users name\n$n - Senders name\n$u - Senders username\n$ru - Replied users username.\n$c - Counter (Goes up by 1 each time it is used)\n$admin - Add this anywhere after the ::, it will make it an admin only command.', parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- bot.sendMessage(chat_id,
- '*More customs:*\n$rn - Replied users name\n$n - Senders name\n$u - Senders username\n$ru - Replied users username.\n$c - Counter (Goes up by 1 each time it is used)\n$admin - Add this anywhere after the ::, it will make it an admin only command.',
- parse_mode='markdown')
- if '/unmute' in msg['text']:
- contents = '*Unmuting users*\n\nIf a user has previously been muted, they can be unmuted with this.\n\n_/unmute @USER\n/unmute (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/link' in msg['text']:
- contents = '*Restricting links*\n\nWith this command, you can restrict your users from sending invite links. If one is sent, it will be deleted. Admins still have the ability to send links.'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/ban' in msg['text']:
- contents = '*Banning users*\n\nThis allows you to reply to someones message (or /ban @username), and remove them from the group. They cannot join back unless they are unbanned (see /unban).\n\n_/ban @USER\n/ban (REPLIED)_'
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, contents, parse_mode='markdown')
- if '/kick' in msg['text']:
- if 'kickme' not in msg['text']:
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, '*Kicking users*\n\nThis allows you to reply to someones message (or /kick @username), and remove them from the group. They can join back as soon as possible.\n\n_/kick @USER\n/kick (REPLIED)_', parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, '*Kicking Users*\n\nThis allows you to reply to someones message (or /kick @username), and remove them from the group. They can join back as soon as possible. \n\n_/kick @USER\n/kick (REPLIED)_', parse_mode='markdown')
- def catchuser():
- if str(msg['from']['id']) in str(open("data/listofusers.data", "r").read()):
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- word = str(msg['from']['id']) # dummy word. you take it from input
- # iterate over lines, and print out line numbers which contain
- # the word of interest.
- for i, line in enumerate(lines):
- if word in line: # or word in line.split() to search for full words
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- if 'username' in msg['from']:
- adminUser = str(msg['from']['username'])
- else:
- adminUser = "var?empty"
- replace_line("data/listofusers.data", i, str(msg['from']['id']) + '>:>' + adminUser + '\n')
- else:
- if 'username' in msg['from']:
- usernameGet = str(msg['from']['username'])
- else:
- usernameGet = 'var?empty'
- open("data/listofusers.data", "a").write(str(msg['from']['id']) + '>:>' + usernameGet.lower() +'\n')
- def idktbh():
- if str(msg['chat']['id']) in str(open("data/listofgroups.data", "r").read()):
- ()
- else:
- open("data/listofgroups.data", "a").write(str(msg['chat']['id']) + '\n')
- if isPrivateMessage == False:
- t = threading.Thread(target=idktbh)
- t.start()
- def catchadmin():
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- if bot.getChatMember(chat_id, msg['from']['id']) in bot.getChatAdministrators(chat_id):
- adminStatus = True
- elif str(msg['from']['id']) in open(str(chat_id) + '/data/admin.txt', 'r').read():
- adminStatus = True
- else:
- #bad_words = [str(msg['from']['id'])]
- #with open(chat_id + '/data/adminlist.data', 'r') as oldfile, open(chat_id + '/data/adminlist.data', 'w') as newfile:
- # for line in oldfile:
- # if not any(bad_word in line for bad_word in bad_words):
- # newfile.write(line)
- fn = str(msg['chat']['id']) + '/data/adminlist.data'
- f = open(fn)
- output = []
- for line in f:
- if str(msg['from']['id']) != line.strip():
- output.append(line)
- f.close()
- f = open(fn, 'w')
- f.writelines(output)
- f.close()
- else:
- if bot.getChatMember(chat_id, messageFromID) in bot.getChatAdministrators(chat_id):
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "rb"):
- pass
- else:
- with open(chat_id + "/data/adminlist.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- word = str(msg['from']['id']) # dummy word. you take it from input
- # iterate over lines, and print out line numbers which contain
- # the word of interest.
- for i, line in enumerate(lines):
- if word in line: # or word in line.split() to search for full words
- #print("Word \"{}\" found in line {}".format(word, i + 1))
- print(i)
- if 'username' in msg['from']:
- adminUser = str(msg['from']['username'])
- else:
- adminUser = "var?empty"
- replace_line(str(chat_id) + '/data/adminlist.data', i, str(msg['from']['id']) + '\n')
- else:
- if 'username' in msg['from']:
- adminUser = str(msg['from']['username'])
- else:
- adminUser = "var?empty"
- open(chat_id + "/data/adminlist.data", "a").write(str(msg['from']['id']) + '\n')
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt", "r").read():
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "rb"):
- pass
- else:
- if bot.getChatMember(chat_id, messageFromID) in bot.getChatAdministrators(chat_id):
- pass
- else:
- if str(msg['from']['id']) in str(open(chat_id + "/data/adminlist.data", "rb")):
- with open(chat_id + "/data/adminlist.data", 'r') as f:
- lines = f.read().split("\n")
- word = str(msg['from']['id']) #this shit sucks lmao
- for i, line in enumerate(lines):
- if word in line:
- foundLine = i
- if 'username' in msg['from']:
- adminUser = str(msg['from']['username'])
- else:
- adminUser = 'var?empty'
- replace_line(chat_id + '/data/adminlist.data', i, str(msg['from']['id']) + '\n')
- else:
- if 'username' in msg['from']:
- adminUser = str(msg['from']['username'])
- else:
- adminUser = 'var?empty'
- open(chat_id + "/data/adminlist.data", "a").write(str(msg['from']['id']) + '\n')
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "rb"):
- with open(chat_id + "/data/adminlist.data", 'r') as f:
- lines = f.read().split("\n")
- # print(" {}".format(len(lines)))
- word = str(msg['from']['id'])
- for i, line in enumerate(lines):
- if word in line:
- foundLine = i
- if 'username' in msg['from']:
- adminUser = str(msg['from']['username'])
- else:
- adminUser = "var?empty"
- replace_line(str(chat_id) + '/data/adminlist.data', i, '')
- with open(str(chat_id) + '/data/adminlist.data', 'r+') as file:
- for line in file:
- if not line.isspace():
- file.write(line)
- if isPrivateMessage == False:
- t = threading.Thread(target=catchadmin)
- t.start()
- if '/listgroups' in message:
- if msg['from']['id'] == 374986841:
- bot.sendMessage(chat_id, str(open("data/listofgroups.data", "r").read()))
- if '/listusers' in message:
- if msg['from']['id'] == 374986841:
- bot.sendMessage(chat_id, str(open("data/listofusers.data", "r").read()))
- if '/broadcast ' in message:
- if msg['from']['id'] == 374986841:
- broadcast = str(msg['text'][11:])
- strAdmins = str(open("data/listofgroups.data", "r").read())
- adminLine = strAdmins.split('\n')
- for i in range(len(adminLine)):
- print(adminLine[i])
- bot.sendMessage(adminLine[i], broadcast)
- findText = re.findall(r'[\u0600-\u06FF]+', str(message))
- def thisYes():
- if messageFromID in open(chat_id + '/data/adminlist.data', 'r').read():
- ()
- else:
- if "True" in open(str(chat_id) + "/data/arabic.txt", "r").read():
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt", "r").read():
- ()
- else:
- bot.kickChatMember(chat_id, msg['from']['id'])
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
- bot.sendMessage(chat_id, "Arabic detected." + usersName + " has been banned.")
- if findText == []:
- ()
- else:
- t = threading(target=thisYes)
- t.start()
- if 'username' in msg['from']:
- username = str("@" + msg['from']['username'])
- else:
- username = msg['from']['first_name']
- if 'caption' in msg:
- caption = msg['caption']
- else:
- caption = 'None'
- if 'voice' in msg:
- voiceMessage = msg['voice']['file_id']
- else:
- voiceMessage = 'None'
- if 'photo' in msg:
- print(str(msg['from']['first_name']) + " sent a photo.")
- if messageType != 'private':
- if os.path.isfile("rooms/" + str(messageFromID) + "wins.txt") == False:
- open("rooms/" + str(messageFromID) + "wins.txt", "w").write("0")
- if os.path.isfile("rooms/" + str(messageFromID) + "money.txt") == False:
- open("rooms/" + str(messageFromID) + "money.txt", "w").write("100")
- if os.path.isfile(str(chat_id) + "/messagecount.txt") == False:
- open(str(chat_id) + "/messagecount.txt", "w").write("1")
- else:
- minus = int(str(open(str(chat_id) + "/messagecount.txt", "r+").readlines()).replace("[", "").replace(
- "'", "").replace("]", "")) + 1
- open(str(chat_id) + "/messagecount.txt", "w").write(str(minus))
- if os.path.isfile(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt") == False:
- open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "w").write("1")
- else:
- minus = int(
- str(open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r+").readlines()).replace("[", "").replace(
- "'", "").replace("]", "")) + 1
- open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "w").write(str(minus))
- photo = msg['photo']
- else:
- photo = 'None'
- if 'reply_to_message' in msg:
- messageReply = msg['reply_to_message']['from']['id']
- else:
- messageReply = 'None'
- def stickerThing():
- print('NOTYET')
- if 'sticker' in msg:
- t = threading.Thread(target=stickerThing)
- t.start()
- if 'reply_to_message' in msg:
- if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == False:
- usersName = str(msg['reply_to_message']['from']['first_name'][:15])
- else:
- usersName = str(open("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt").read())
- else:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- usersName = str(msg['from']['first_name'][:15])
- else:
- usersName = str(open("data/n" + str(messageFromID) + ".txt").read())
- if messageType == 'private':
- if "/setmoney " in message:
- if msg['from']['id'] == 374986841:
- messagE = msg['text'].lower()[10:]
- user = messagE.split("::")[1]
- number = messagE.split("::", 1)[0]
- open('rooms/' + str(user) + "money.txt", 'w').write(str(number))
- bot.sendMessage(chat_id, "Money changed.")
- if "/groupcount" in message:
- if msg['from']['id'] == 374986841:
- bashCommand = "find /home/spoon/*/*messagecount.txt -type f | wc -l"
- command = subprocess.check_output(['bash', '-c', bashCommand])
- b = command
- bot.sendMessage(chat_id, "I am in " + str(b.decode('utf-8')).replace('\n', "") + " groups currently!")
- if "/setwins " in message:
- if msg['from']['id'] == 374986841:
- messagE = msg['text'].lower()[9:]
- user = messagE.split("::")[1]
- number = messagE.split("::", 1)[0]
- open('rooms/' + str(user) + "wins.txt", 'w').write(str(number))
- bot.sendMessage(chat_id, "Wins changed.")
- if 'data' in msg:
- global warnd
- isInlineResponse = True
- messageInlineData = msg['data']
- print(messageInlineData)
- else:
- isInlineResponse = False
- messageInlineData = 'None'
- global warnd
- global promoted
- messageFromID = messageFromID
- if ".spam" in message:
- if msg['from']['id'] == 374986841:
- if startSpam == None:
- print('ye')
- if startSpam == True:
- startSpam = False
- bot.sendMessage(chat_id, "Deactivate.")
- else:
- startSpam = True
- bot.sendMessage(chat_id, "Activate.")
- #DEFINE COMMANDS
- smartball = ['Today', 'Tomorrow', 'Next week', 'Next month', 'Next month, on the 9th', 'Right now', 'In 5 minutes', 'In 8 hours', 'In 10 years', 'When the time is right (right now)', '24 hours', '48 hours', '2 weeks']
- eightball = ["Not so sure", "That could be possible", "Most likely", "Absolutely not", "Outlook is good",
- "I see good things happening", "Never",
- "Negative", "Could be", "Yes", "No", "Possible, but not probable", 'Perhaps']
- easyeightball = ['Yup', 'Without a doubt', 'Not so sure', 'That could be possible','Perhaps', 'Most likely', 'Absolutely not', 'Never', 'Yup', 'Negative', 'Yes', 'No']
- jokes = ["Why did the boy drop his ice cream? Because he was hit by a bus.", "A dyslexic man walks into a bra.",
- "What is green and has wheels. Grass, I lied about the wheels.",
- "What is red and smells like blue paint? Red paint.",
- "Knock knock. Who's there? Dave. Dave who? Dave began to break into tears as his Grandmother's Alzheimer's had gotten progressively worse.",
- "What is brown and sticky? A stick.",
- "A horse walked into a bar. Several people got up and left as they spotted the potential danger in the situation.",
- "How do you make a plumber cry? You kill his family.",
- "A man walks into a bar, he is an alcoholic and he is ruining his family.",
- "What does an Eagle and a Mole have in common? They both live underground. Apart from the Eagle.",
- "Why did Suzie fall off the swing? She had no arms.",
- "A duck walks into a bar, the bartender says 'What'll it be?' The duck doesn't say anything because it is a duck.",
- "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."]
- commandsList = ["/blacklist", "/portrait", "/leaderboard", "/state", "/bw", "/speak", "/tts", "/read", "/weather", "/when", "/link", "/format", "/uptime", "/detect", "/play", "/dog", "/unrestrict", "/nomedia", "/makeup", "/lock", "/antibot", 'hi bot', '/gt', '/scramble', "/m8", "/toggles", "/magic8", "/pin", '/polaroid', '/color', '/colour', '/start', '/rblur', '/swirl', '/help', "/greet", "/eb", '/com', '/id', '/google', '/title', '/time', '/limit', '/give', '/stick', '/chatid', '/pin', '/unban', '/ud', '/slap', '/promote', '/demote', '/unmute', 'hey bot', '/unban', '/byebot', '/rt', "/roll", '/wt', "/warn", "/wel", "/me", "/reset", "/callme", "/forget", "/imagesearch", "/ban", "/kick", "/contour", "/invert", "/saturate", "/posterize", "/equalize", "/blur", "/sharpen", "/solarize", "/caption", "/photo"]
- #if 'text' in msg:
- # searchMeaning = re.search('what does (.+?) mean', str(msg['text']))
- def define2():
- heart = u'\u2764'
- term = str(searchMeaning.group(1))
- notTerm = {'it', 'this', 'these', 'those', 'that'}
- if term not in notTerm:
- if term != notTerm:
- if msg['from']['id'] == 113032140:
- if term == "opinion":
- bot.sendMessage(chat_id, "Fuck off cunt.")
- if term == "spoon":
- bot.sendMessage(chat_id, "The creator of this bot @spoon" + heart)
- elif term == "sierra":
- bot.sendMessage(chat_id,
- "*Sierra:*\n\nA fucking dumbass that thinks A11 is the best thing to come to this earth. He also overuses gifs and sends them as files. He does not know the definition of opinion, either.",
- parse_mode="markdown")
- elif term == "smitty":
- bot.sendMessage(chat_id,
- "*Smitty:*\n\nA fucking dumbass that thinks A11 is the best thing to come to this earth. He also overuses gifs and sends them as files. He does not know the definition of opinion, either.",
- parse_mode="markdown")
- elif term == "sierra":
- bot.sendMessage(chat_id,
- "*Sierra:*\n\nA fucking dumbass that thinks A11 is the best thing to come to this earth. He also overuses gifs and sends them as files. He does not know the definition of opinion, either.",
- parse_mode="markdown")
- elif term == "panda":
- bot.sendMessage(chat_id,
- "*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.",
- parse_mode="markdown")
- elif term == "ella":
- bot.sendMessage(chat_id,
- "*Ella:*\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.",
- parse_mode="markdown")
- elif term == "awais":
- bot.sendMessage(chat_id,
- "*Awais:*\n\nOne word. Telegod.",
- parse_mode="markdown")
- else:
- term = str(searchMeaning.group(1))
- definition = urbandict.define(term)[0]['def']
- bot.sendMessage(chat_id, "*" + term + "*:\n\n" + definition, parse_mode="markdown")
- def leaderboard():
- with open(str(chat_id) + "/data/numberone.txt", "r") as one:
- for _ in range(2):
- OwnerMessage = one.readline()
- with open(str(chat_id) + "/data/numbertwo.txt", "r") as two:
- for _ in range(2):
- OwnerCoins = two.readline()
- with open(str(chat_id) + "/data/numberthree.txt", "r") as three:
- for _ in range(2):
- OwnerWins = three.readline()
- with open(str(chat_id) + "/data/numberone.txt", "r") as one:
- for _ in range(3):
- OMessages = one.readline()
- with open(str(chat_id) + "/data/numbertwo.txt", "r") as two:
- for _ in range(3):
- OCoins = two.readline()
- with open(str(chat_id) + "/data/numberthree.txt", "r") as three:
- for _ in range(3):
- OWins = three.readline()
- bot.sendMessage(chat_id, '\U0001F465 Leaderboard \U0001F465\n\n\u250cMost Messages Sent\n\u251c' + str(OwnerMessage) + "\u2514Sent " + str(OMessages) + "\n\n\u250cMost Wins\n\u251c" + str(OwnerWins) + "\u2514Won " + str(OWins) + " games" + "\n\n\u250cMost Coins\n\u251c" + str(OwnerCoins) + "\u2514Has " + str(OCoins) + " coins", parse_mode='markdown', disable_web_page_preview='true')
- if '/leaderboard' in message:
- if 'Universal commands' in msg['text']:
- print('S')
- else:
- if 'help' in message:
- bot.sendMessage(chat_id, '*Leaderboard*\n\nLists the users who has the most coins, wins, and sent messages. This varys by group.', parse_mode='markdown')
- else:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id,
- '*Leaderboard*\n\nLists the users who has the most coins, wins, and sent messages. This only works in groups, and it differs based on what group this is used in.',
- parse_mode='markdown')
- else:
- if "True" in open(str(chat_id) + "/data/leaderboard.txt", "r").read():
- t = threading.Thread(target=leaderboard)
- t.start()
- if "/when" in message:
- if 'reply_to_message' in msg:
- if 'forward_date' in msg['reply_to_message']:
- epoch = str(msg['reply_to_message']['forward_date'])
- translate = datetime.datetime.fromtimestamp(float(epoch))
- formatdate = "%m-%d-%y"
- formattime = "%I:%M%p"
- if 'username' in msg['reply_to_message']['forward_from']:
- bot.sendMessage(chat_id, "\u250cMessage from: " + "[" + str(msg['reply_to_message']['forward_from']['first_name']) + "](www.t.me/" + str(msg['reply_to_message']['forward_from']['username']) + ")\n\u251cMessage date: `" + str(translate.strftime(formatdate)) + "`\n\u2514Message time (UTC): `" + str(translate.strftime(formattime)) + "`", parse_mode="markdown", reply_to_message_id=msg['reply_to_message']['message_id'])
- else:
- bot.sendMessage(chat_id, "\u250cMessage from: " + str(msg['reply_to_message']['forward_from']['first_name']) + "\n\u251cMessage date: `" + str(translate.strftime(formatdate)) + "`\n\u2514Message time (UTC): `" + str(translate.strftime(formattime)) + "`", parse_mode='markdown', reply_to_message_id=msg['reply_to_message']['message_id'])
- else:
- epoch = str(msg['reply_to_message']['date'])
- translate = datetime.datetime.fromtimestamp(float(epoch))
- formatdate = "%m-%d-%y"
- formattime = "%I:%M%p"
- if 'username' in msg['reply_to_message']['from']:
- bot.sendMessage(chat_id, "\u250cMessage from: " + "[" + str(
- msg['reply_to_message']['from']['first_name']) + "](www.t.me/" + str(
- msg['reply_to_message']['from']['username']) + ")\n\u251cMessage date: `" + str(
- translate.strftime(formatdate)) + "`\n\u2514Message time (UTC): `" + str(
- translate.strftime(formattime)) + "`", parse_mode="markdown",
- reply_to_message_id=msg['reply_to_message']['message_id'])
- else:
- bot.sendMessage(chat_id, "\u250cMessage from: " + str(
- msg['reply_to_message']['from']['first_name']) + "\n\u251cMessage date: `" + str(
- translate.strftime(formatdate)) + "`\n\u2514Message time (UTC): `" + str(
- translate.strftime(formattime)) + "`", parse_mode='markdown',
- reply_to_message_id=msg['reply_to_message']['message_id'])
- else:
- bot.sendMessage(chat_id, "Reply to a message.")
- def caption():
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- numbe = msg['text'][9:]
- size = numbe.split("::")[1]
- number = numbe.split("::", 1)[0]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- draw = PIL.ImageDraw.Draw(img)
- w, h = img.size
- font = ImageFont.truetype("comic.ttf", int(size))
- text_w, text_h = draw.textsize(number, font)
- draw.text(((w - text_w) // 2, h - text_h), number, (255, 255, 255), font=font)
- img.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- def rblur():
- if chat_id == -1001088621659:
- ()
- else:
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- bashCommand = "convert " + str(msg['reply_to_message']['from']['id']) + ".jpg" + " -radial-blur 10 " + str(
- msg['reply_to_message']['from']['id']) + ".jpg"
- subprocess.check_output(['bash', '-c', bashCommand])
- bot.sendPhoto(chat_id, open(str(msg['reply_to_message']['from']['id']) + ".jpg", "rb"))
- os.remove(filename)
- def swirl():
- if chat_id == -1001088621659:
- ()
- else:
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- bashCommand = "convert " + str(msg['reply_to_message']['from']['id']) + ".jpg" + " -swirl 180 " + str(
- msg['reply_to_message']['from']['id']) + ".jpg"
- subprocess.check_output(['bash', '-c', bashCommand])
- bot.sendPhoto(chat_id, open(str(msg['reply_to_message']['from']['id']) + ".jpg", "rb"))
- os.remove(filename)
- def distort():
- if chat_id == -1001088621659:
- ()
- else:
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- im = Image.open(filename)
- width, height = im.size
- dwidth = str(width/1.05)
- dheight = str(height/1.05)
- bashCommand = "convert " + str(msg['reply_to_message']['from']['id']) + ".jpg" + " -liquid-rescale " + dheight + 'x' + dwidth + " " + str(
- msg['reply_to_message']['from']['id']) + ".jpg"
- subprocess.check_output(['bash', '-c', bashCommand])
- bashCommand = "convert " + str(
- msg['reply_to_message']['from']['id']) + ".jpg" + " -resize " + str(width) + 'x' + str(height) + " " + str(
- msg['reply_to_message']['from']['id']) + ".jpg"
- subprocess.check_output(['bash', '-c', bashCommand])
- bot.sendPhoto(chat_id, open(str(msg['reply_to_message']['from']['id']) + ".jpg", "rb"))
- os.remove(filename)
- def polar():
- text = msg['text'][10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".png"
- bot.download_file(file_id, filename)
- bashCommand = "convert -caption '" + str(text) + "' \
- " + filename + " -thumbnail 480x480 \
- -bordercolor Lavender -border 5x5 -density 144 \
- -gravity center -pointsize 20 -background black \
- -polaroid -15 -resize 50% " + filename
- subprocess.check_output(['bash', '-c', bashCommand])
- bot.sendPhoto(chat_id, open(filename, "rb"))
- os.remove(filename)
- if "/polaroid" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=polar)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=polar)
- t.start()
- if "/swirl" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=swirl)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=swirl)
- t.start()
- if "/distort" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=distort)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=distort)
- t.start()
- def format():
- if 'reply_to_message' in msg:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- format = message[8:].replace(".", "")
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + "." + format
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- img.save("1" + filename)
- bot.sendDocument(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/format " in message:
- t = threading.Thread(target=format)
- t.start()
- #FEEDBACK feature.
- if message.startswith('/feedback '):
- if isPrivateMessage == True:
- feedBack = str(msg['text'])[10:]
- toKen = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(15))
- open('feedback/' + toKen + '.txt', 'w').write(str(msg['from']['id']) + '::' + str(msg['message_id']) + "::Pending")
- bot.sendMessage(chat_id, '*Feedback sent:*' + '\n_' + feedBack + '_\n\n' + 'Feedback has been sent, you should get a response soon!', parse_mode='markdown')
- if 'username' in msg['from']:
- bot.sendMessage(374986841, '*Feedback received:*' + '\n[' + str(msg['from']['first_name']) + '](www.t.me/' + str(msg['from']['username']) + '): _' + feedBack + '_\n\n' + '*Ticket*' + '\n\u2514<' + str(toKen) + ">", parse_mode='markdown')
- else:
- bot.sendMessage(374986841, '*Feedback received:*' + '\n' + str(msg['from']['first_name']) + ' (' + str(msg['from']['id']) + '): _' + feedBack + '_\n\n' + '*Ticket*' + '\n\u2514<' + str(toKen) + ">", parse_mode='markdown')
- else:
- bot.sendMessage(chat_id, 'This only works in PM!')
- if message.startswith('/freply '):
- if msg['from']['id'] == 374986841:
- response = str(msg['text'])[8:]
- replyMessage = str(msg['reply_to_message']['text'])
- ticket = replyMessage[replyMessage.find("<") + 1:replyMessage.find(">")]
- messageInfo = str(open('feedback/' + str(ticket) + '.txt', 'r').read()).split('::')
- #open('feedback/' + str(messageInfo[1]) + '.txt', 'w').write('1')
- #if os.path.isfile('feedback/' + messageInfo[0] + '.txt') == True:
- # minus = int(str(open('feedback/' + messageInfo[1] + '.txt',
- # "r+").readlines()).replace("[", "").replace("'",
- # "").replace(
- # "]", "")) + 1
- #open('feedback/' + messageInfo[0] + '.txt', "w").write(str(minus))
- bot.sendMessage(messageInfo[0], '*New Response!*\n\n_' + response + '_', parse_mode='markdown', reply_to_message_id=messageInfo[1])
- os.remove('feedback/' + str(ticket) + '.txt')
- def saturatee():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- convert = PIL.ImageEnhance.Color(img)
- img2 = convert.enhance(int(number))
- img2.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- def blackandwhite():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = Image.open(filename)
- img2 = img.convert('L')
- img2.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- def noLinks():
- if "True" in open(str(chat_id) + "/data/link.txt", "r"):
- if str(messageFromID) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- ()
- else:
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt", "r").read():
- ()
- else:
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
- bot.sendMessage(chat_id,
- "Sorry, but you cannot send invite links at the time. /link to turn this feature off.")
- if "t.me" in message.lower():
- t = threading.Thread(target=noLinks)
- t.start()
- if "telegram.me" in message.lower():
- t = threading.Thread(target=noLinks)
- t.start()
- if "telegram.dog" in message.lower():
- t = threading.Thread(target=noLinks)
- t.start()
- if "/bw" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- if 'help' in msg['text']:
- pass
- else:
- t = threading.Thread(target=blackandwhite)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=blackandwhite)
- t.start()
- def tts():
- TTS = gTTS(msg['text'][5:])
- TTS.save(str(msg['from']['id']) + 'voice.ogg')
- Bot.send_voice(chat_id, voice=open(str(msg['from']['id']) + 'voice.ogg', 'rb'))
- os.remove(str(msg['from']['id']) + 'voice.ogg')
- def executeSafe():
- cv_img = []
- for img in glob.glob('/home/*spoon/*/messages/' + str(msg['from']['id']) + 'spam.txt'):
- os.remove(img)
- pass
- print('Done with deleting spam.')
- for img in glob.glob('/home/*spoon/*/messages/' + str(msg['from']['id']) + 'cache.txt'):
- os.remove(img)
- pass
- print('Done with deleting cache.')
- for img in glob.glob('/home/*spoon/*/data/scramble.txt'):
- open(img, 'w').write('False')
- print(img)
- pass
- for img in glob.glob('/home/*spoon/*/data/type.txt'):
- open(img, 'w').write('False')
- print(img)
- pass
- for img in glob.glob('/home/*spoon/*/data/states.txt'):
- open(img, 'w').write('False')
- print(img)
- pass
- print('Resetting all games')
- if safetyNet == False:
- safetyNet = True
- t = threading.Thread(target=executeSafe)
- t.start()
- if message.startswith('/tts '):
- if isPrivateMessage == True:
- if 'help' in msg['text']:
- pass
- else:
- t = threading.Thread(target=tts)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/tts.txt", "r"):
- t = threading.Thread(target=tts)
- t.start()
- def contour():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- im = filename
- img = PIL.Image.open(im)
- im1 = img.filter(ImageFilter.CONTOUR)
- im1.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- def blur():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[5:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- im = filename
- img = PIL.Image.open(im)
- im1 = img.filter(ImageFilter.GaussianBlur(radius=int(number)))
- im1.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- def sharpen():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- im = filename
- img = PIL.Image.open(im)
- im1 = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
- im1.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- def solarize():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- convert = PIL.ImageOps.solarize(img, threshold=128)
- convert.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/solarize" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- if 'help' in msg['text']:
- pass
- else:
- t = threading.Thread(target=solarize)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=solarize)
- t.start()
- def portrait():
- if 'reply_to_message' in msg:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- bot.sendMessage(chat_id, 'I am now attempting to blur the background of this photo. This could take a minute, or two.')
- bashCommand = "python3 portrait.py " + filename + " " + str(msg['from']['id']) + " "
- command = subprocess.check_output(['bash', '-c', bashCommand])
- b = command
- try:
- bot.sendPhoto(chat_id, open(str(msg['from']['id']) + '3.jpg', "rb"), reply_to_message_id=msg['message_id'])
- os.remove(str(msg['from']['id']) + '1.jpg')
- os.remove(str(msg['from']['id']) + '2.jpg')
- os.remove(str(msg['from']['id']) + '3.jpg')
- except:
- bot.sendMessage(chat_id, 'I could not process this photo, try photos with a subject and a background.')
- os.remove(str(msg['from']['id']) + '1.jpg')
- os.remove(str(msg['from']['id']) + '2.jpg')
- os.remove(str(msg['from']['id']) + '3.jpg')
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if message.startswith('/tl'):
- newer = str(msg['text'][4:].split(' ')[0])
- if newer == 'help':
- pass
- else:
- if 'reply_to_message' in msg:
- language = str(msg['text'][4:].split(' ')[0])
- if language == '':
- language = 'en'
- toTranslate = str(msg['reply_to_message']['text'])
- Translated = str(translator.translate(toTranslate, dest=language).text)
- Selectedlan = str(translator.translate(toTranslate, dest=language).src).capitalize().upper()
- Movedlan = str(translator.translate(toTranslate, dest=language).dest).upper()
- newText = Translated
- bot.sendMessage(chat_id, '*' + Selectedlan + ' \u2192 ' + Movedlan + ':*\n' + newText, parse_mode='markdown')
- else:
- toTranslate = str(msg['text'][4:])
- language = str(msg['text'][4:].split(' ')[0])
- newText = str(msg['text'][4:].split(' ', 1)[1])
- try:
- Translated = str(translator.translate(toTranslate, dest=language).text)
- Selectedlan = str(translator.translate(toTranslate, dest=language).src).capitalize().upper()
- Movedlan = str(translator.translate(toTranslate, dest=language).dest).upper()
- newText = str(Translated.split(' ', 1)[1])
- bot.sendMessage(chat_id, '*' + Selectedlan + ' \u2192 ' + Movedlan + ':*\n' + newText, parse_mode='markdown')
- except:
- Translated = str(translator.translate(toTranslate, dest='en').text)
- Selectedlan = str(translator.translate(toTranslate, dest='en').src).capitalize().upper()
- Movedlan = str(translator.translate(toTranslate, dest='en').dest).capitalize().upper()
- print(Translated)
- if msg['text'].lower()[4:] == Translated.lower():
- pass
- else:
- bot.sendMessage(chat_id, '*' + Selectedlan + ' \u2192 ' + Movedlan + ':*\n' + Translated, parse_mode='markdown')
- #if "/portrait" in message:
- # if 'private' in msg['chat']['type']:
- # if 'reply_to_message' in msg:
- # t = threading.Thread(target=portrait)
- # t.start()
- # else:
- # if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- # t = threading.Thread(target=portrait)
- # t.start()
- #def makeup():
- # if 'reply_to_message' in msg:
- # try:
- # Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- # number = message[10:]
- # file_id = msg['reply_to_message']['photo'][-1]['file_id']
- # filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- # bot.download_file(file_id, filename)
- # image = face_recognition.load_image_file(filename)
- #
- # # Find all facial features in all the faces in the image
- # face_landmarks_list = face_recognition.face_landmarks(image)
- #
- # for face_landmarks in face_landmarks_list:
- # pil_image = Image.fromarray(image)
- # d = ImageDraw.Draw(pil_image, 'RGBA')
- # Make the eyebrows into a nightmare
- # d.polygon(face_landmarks['left_eyebrow'], fill=(68, 54, 39, 128))
- # d.polygon(face_landmarks['right_eyebrow'], fill=(68, 54, 39, 128))
- # d.line(face_landmarks['left_eyebrow'], fill=(68, 54, 39, 150), width=5)
- # d.line(face_landmarks['right_eyebrow'], fill=(68, 54, 39, 150), width=5)
- #
- # # Gloss the lips
- # d.polygon(face_landmarks['top_lip'], fill=(150, 0, 0, 128))
- # d.polygon(face_landmarks['bottom_lip'], fill=(150, 0, 0, 128))
- #3 d.line(face_landmarks['top_lip'], fill=(150, 0, 0, 64), width=8)
- # d.line(face_landmarks['bottom_lip'], fill=(150, 0, 0, 64), width=8)
- # Sparkle the eyes
- # d.polygon(face_landmarks['left_eye'], fill=(255, 255, 255, 30))
- # d.polygon(face_landmarks['right_eye'], fill=(255, 255, 255, 30))
- # Apply some eyeliner
- # d.line(face_landmarks['left_eye'] + [face_landmarks['left_eye'][0]], fill=(0, 0, 0, 110),
- #3 width=6)
- #33 d.line(face_landmarks['right_eye'] + [face_landmarks['right_eye'][0]], fill=(0, 0, 0, 110),
- # width=6)
- #pil_image.convert().save("1" + filename)
- # bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- # os.remove(filename)
- # os.remove("1" + filename)
- # except:
- # ()
- # else:
- # bot.sendMessage(chat_id, "Reply to a photo.")
- #if "/makeup" in message:
- # if 'private' in msg['chat']['type']:
- # if 'reply_to_message' in msg:
- # t = threading.Thread(target=makeup)
- # t.start()
- #else:
- # if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- # t = threading.Thread(target=makeup)
- # t.start()
- def detect_labels(path):
- client = implicit(vision.ImageAnnotatorClient())
- with io.open(path, 'rb') as image_file:
- content = image_file.read()
- image = types.Image(content=content)
- response = client.label_detection(image=image)
- labels = response.label_annotations
- selection = ['I think this is ', "This might be ", "This could be "]
- bot.sendMessage(chat_id, random.choice(selection) + str(labels[0].description), reply_to_message_id=msg['message_id'])
- def detect():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- detect_labels(filename)
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/detect" in message:
- t = threading.Thread(target=detect)
- t.start()
- def readtext(path):
- client = vision.ImageAnnotatorClient()
- # [START migration_text_detection]
- with io.open(path, 'rb') as image_file:
- content = image_file.read()
- image = types.Image(content=content)
- response = client.text_detection(image=image)
- texts = response.text_annotations
- if len(texts[0].description) < 100:
- bot.sendMessage(chat_id, 'I read:\n*{}*'.format(texts[0].description), parse_mode='markdown', reply_to_message_id=msg['message_id'])
- else:
- bot.sendMessage(chat_id, 'I read:\n*{}*'.format(texts[0].description[:100]) + "\n(Text limited to 100 characters.)", parse_mode='markdown', reply_to_message_id=msg['message_id'])
- def read():
- if 'reply_to_message' in msg:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- readtext(filename)
- os.remove(filename)
- os.remove("1" + filename)
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- def play():
- try:
- query_string = urllib.parse.urlencode({"search_query": msg['text'][6:]})
- html_content = urllib.request.urlopen("http://www.youtube.com/results?" + query_string)
- search_results = re.findall(r'href=\"\/watch\?v=(.{11})', html_content.read().decode())
- class AppURLopener(urllib.request.FancyURLopener):
- version = "Chrome/60.0.3112.113"
- opener = AppURLopener()
- fp = opener.open("http://www.youtube.com/watch?v=" + search_results[0])
- mybytes = fp.read()
- open("text.txt", "w").write(str(mybytes))
- mystr = mybytes.decode("utf8")
- fp.close()
- titlehtml = ',"title":"(.+?)","'
- titlecompile = re.compile(titlehtml)
- viewshtml = 'views-info"><div class="watch-view-count">(.+?) views</div>'
- viewscompile = re.compile(viewshtml)
- views = re.findall(viewscompile, mystr)
- authorhtml = ',"author":"(.+?)",'
- authorcompile = re.compile(authorhtml)
- author = re.findall(authorcompile, mystr)
- likeshtml = 'aria-label="like this video along with (.+?) other people"'
- likescompile = re.compile(likeshtml)
- likes = re.findall(likescompile, mystr)
- dislikehtml = 'aria-label="dislike this video along with (.+?) other people"'
- dislikecompile = re.compile(dislikehtml)
- dislikes = re.findall(dislikecompile, mystr)
- timehtml = '<strong class="watch-time-text">Published on (.+?)</strong></div>'
- timecompile = re.compile(timehtml)
- timevideo = re.findall(timecompile, mystr)
- authorlink = '<link itemprop="url" href="http://www.youtube.com/user/(.+?)">'
- authorlink2 = '<a href="/channel/(.+?)"'
- authorlink2compile = re.compile(authorlink2)
- authorlink2 = re.findall(authorlink2compile, mystr)
- authorlinkcompile = re.compile(authorlink)
- authorlink = re.findall(authorlinkcompile, mystr)
- if likes == []:
- likes = '0'
- if dislikes == []:
- dislikes = '0'
- if len(str(re.findall(titlecompile, mystr))) != 25:
- if len(str(re.findall(titlecompile, mystr))) > 25:
- title = re.findall(titlecompile, mystr)[0][:25] + '...'
- else:
- title = re.findall(titlecompile, mystr)[0]
- else:
- title = re.findall(titlecompile, mystr)[0]
- if len(author[0]) != 20:
- if len(author[0]) > 25:
- author = re.findall(authorcompile, mystr)[:20]
- else:
- author = re.findall(authorcompile, mystr)
- else:
- author = re.findall(authorcompile, mystr)
- try:
- bot.sendMessage(chat_id, '[' + title + '](' + "http://www.youtube.com/watch?v=" + search_results[0]
- + ')' + '\n \u250c*Author* - [' + author[0] + '](http://www.youtube.com/user/' +
- authorlink[0]
- + ')\n \u251c*Views* - ' + views[0] + '\n \u251c*Date* - ' + timevideo[0]
- + '\n \u251c*Likes* - \U0001f44d ' +
- likes[0] + '\n \u2514*Dislikes* - \U0001f44e ' +
- dislikes[0], parse_mode='markdown', disable_web_page_preview='False',
- reply_to_message_id=msg['message_id'])
- except:
- bot.sendMessage(chat_id, '[' + title + '](' + "http://www.youtube.com/watch?v=" + search_results[0]
- + ')' + '\n \u250c*Author* - [' + author[0] + '](http://www.youtube.com/user/' +
- authorlink2[0]
- + ')\n \u251c*Views* - ' + views[0] + '\n \u251c*Date* - ' + timevideo[0]
- + '\n \u251c*Likes* - \U0001f44d ' +
- likes[0] + '\n \u2514*Dislikes* - \U0001f44e ' +
- dislikes[0], parse_mode='markdown', disable_web_page_preview='False',
- reply_to_message_id=msg['message_id'])
- except:
- bot.sendMessage(chat_id, '\U0001F6AB - No results found', reply_to_message_id=msg['message_id'])
- if message.startswith('/play '):
- t = threading.Thread(target=play)
- t.start()
- def equalize():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- convert = PIL.ImageOps.equalize(img)
- convert.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/equalize" in message:
- t = threading.Thread(target=equalize)
- t.start()
- def posterize():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- convert = PIL.ImageOps.posterize(img, 2)
- convert.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/posterize" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=posterize)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=posterize)
- t.start()
- def invert():
- if 'reply_to_message' in msg:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- number = message[10:]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- convert = PIL.ImageOps.invert(img)
- convert.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/invert" in message:
- t = threading.Thread(target=invert)
- t.start()
- def saturate():
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- convert = PIL.ImageEnhance.Color(img)
- img2 = convert.enhance(10)
- img2.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- bot.sendMessage(chat_id, "/saturate <Amount of saturation in numbers>")
- def captionb():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- numbe = msg['text'][10:]
- size = numbe.split("::")[1]
- number = numbe.split("::", 1)[0]
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- img = PIL.Image.open(filename)
- draw = PIL.ImageDraw.Draw(img)
- w, h = img.size
- font = ImageFont.truetype("comic.ttf", int(size))
- text_w, text_h = draw.textsize(number, font)
- draw.text(((w - text_w) // 2, h - text_h), number, (0, 0, 0), font=font)
- img.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- ()
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- def captionerror():
- bot.sendMessage(chat_id, "/caption text::textsize (in numbers)")
- def captionerrorb():
- bot.sendMessage(chat_id, "/captionb text::textsize (in numbers)")
- if message == "/caption":
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=captionerror)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=captionerror)
- t.start()
- if "/caption " in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=caption)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=caption)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please reply to a photo.")
- if "/rblur" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=rblur)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=rblur)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please reply to a photo.")
- def weather():
- try:
- weather = Weather(unit=Unit.FAHRENHEIT)
- weatherc = Weather(unit=Unit.CELSIUS)
- locationinfo = msg['text'].lower()[9:]
- location = weather.lookup_by_location(locationinfo)
- locationc = weatherc.lookup_by_location(locationinfo)
- condition = location.condition()
- conditionc = locationc.condition()
- weatheremoji = ""
- if str(condition.text().lower()) == "tornado":
- weatheremoji = "\U0001F32A"
- elif str(condition.text().lower()) == "showers":
- weatheremoji = "\U0001F327"
- elif str(condition.text().lower()) == "scattered showers":
- weatheremoji = "\U0001F327"
- elif str(condition.text().lower()) == "rain":
- weatheremoji = "\U0001F327"
- elif str(condition.text().lower()) == "mixed rain and hail":
- weatheremoji = "\U0001F327"
- elif str(condition.text().lower()) == "hot":
- weatheremoji = "\U0001F525"
- elif str(condition.text().lower()) == "tropical storm":
- weatheremoji = "\U0001F300"
- elif str(condition.text().lower()) == "hurricane":
- weatheremoji = "\U0001F300"
- elif str(condition.text().lower()) == "thunderstorms":
- weatheremoji = "\U0001F329"
- elif str(condition.text().lower()) == "isolated thunderstorms":
- weatheremoji = "\U0001F329"
- elif str(condition.text().lower()) == "scattered thunderstorms":
- weatheremoji = "\U0001F329"
- elif str(condition.text().lower()) == "mixed rain and snow":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "mixed rain and sleet":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "mixed snow and sleet":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "freezing drizzle":
- weatheremoji = "\U00002744\U0001F4A7"
- elif str(condition.text().lower()) == "drizzle":
- weatheremoji = "\U0001F4A7"
- elif str(condition.text().lower()) == "freezing rain":
- weatheremoji = "\U00002744\U0001F327"
- elif str(condition.text().lower()) == "snow flurries":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "heavy snow":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "scattered snow showers":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "blowing snow":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "snow":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "sleet":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "hail":
- weatheremoji = "\U0001F327"
- elif str(condition.text().lower()) == "dust":
- weatheremoji = "\U0001F32B"
- elif str(condition.text().lower()) == "foggy":
- weatheremoji = "\U0001F32B"
- elif str(condition.text().lower()) == "haze":
- weatheremoji = "\U0001F32B"
- elif str(condition.text().lower()) == "smoky":
- weatheremoji = "\U0001F32B"
- elif str(condition.text().lower()) == "blustery":
- weatheremoji = "\U0001F4A8"
- elif str(condition.text().lower()) == "windy":
- weatheremoji = "\U0001F4A8"
- elif str(condition.text().lower()) == "cold":
- weatheremoji = "\U00002744"
- elif str(condition.text().lower()) == "cloudy":
- weatheremoji = "\U00002601"
- elif str(condition.text().lower()) == "partly cloudy":
- weatheremoji = "\U0001F325"
- elif str(condition.text().lower()) == "thundershowers":
- weatheremoji = "\U000026C8"
- elif str(condition.text().lower()) == "snow showers":
- weatheremoji = "\U0001F328"
- elif str(condition.text().lower()) == "not available":
- weatheremoji = "\U0000274C"
- elif str(condition.text().lower()) == "mostly cloudy (night)":
- weatheremoji = "\U00002601"
- elif str(condition.text().lower()) == "mostly cloudy (day)":
- weatheremoji = "\U000026C5"
- elif str(condition.text().lower()) == "mostly cloudy":
- weatheremoji = "\U000026C5"
- elif str(condition.text().lower()) == "partly cloudy":
- weatheremoji = "\U000026C5"
- elif str(condition.text().lower()) == "partly cloudy (day)":
- weatheremoji = "\U000026C5"
- elif str(condition.text().lower()) == "partly cloudy (night)":
- weatheremoji = "\U00002601"
- elif str(condition.text().lower()) == "clear (night)":
- weatheremoji = "\U0001F315"
- elif str(condition.text().lower()) == "clear":
- weatheremoji = "\U0001F31E"
- elif str(condition.text().lower()) == "sunny":
- weatheremoji = "\U0001F31E"
- elif str(condition.text().lower()) == "fair (day)":
- weatheremoji = "\U000026C5"
- elif str(condition.text().lower()) == "fair (night)":
- weatheremoji = "\U00002601"
- val = int((float(location.wind()['direction']) / 22.5) + .5)
- arr = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
- direction = str(arr[(val % 16)])
- bot.sendMessage(chat_id, "*The weather in " + locationinfo.title() + ":*\n\u250c" + condition.text() + " " + weatheremoji + "\n\u251c" + condition.temp() + "\u00b0F (" + conditionc.temp() + "\u00b0C)\n\u251cWindspeed of " + location.wind()["speed"] + " MPH(" + direction + ")\n\u251cSunset at " + location.astronomy()['sunset'] + "\n\u2514Sunrise at " + location.astronomy()['sunrise'], parse_mode="markdown")
- except:
- bot.sendMessage(chat_id, "I could not find the place you are looking for. Perhaps being more specific?")
- if "/weather " in message:
- if "hell" in message:
- bot.sendMessage(chat_id,
- "*The weather in Hell:*\n\u250cHot \U0001F525\n\u251c187\u00b0F (86\u00b0C)\n\u2514Windspeed of 73 MPH(NW)", parse_mode="markdown")
- else:
- t = threading.Thread(target=weather)
- t.start()
- if "/bitcoin" in message:
- bot.sendMessage(chat_id, "The current price of bitcoin is *$" + str(Bitfinex().get_current_price()) + "*", parse_mode="markdown")
- if message == "/captionb":
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=captionerrorb)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- t = threading.Thread(target=captionerrorb)
- t.start()
- if message.startswith("/captionb "):
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=captionb)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=captionb)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please reply to a photo.")
- if message == "/saturate":
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=saturate)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=saturate)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please respond to a photo.")
- if "/contour" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=contour)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=contour)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please respond to a photo.")
- if "/blur " in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=blur)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=blur)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please respond to a photo.")
- if "/sharpen" in message:
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=sharpen)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=sharpen)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please respond to a photo.")
- if message.startswith("/saturate "):
- if 'private' in msg['chat']['type']:
- if 'reply_to_message' in msg:
- t = threading.Thread(target=saturatee)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- if 'reply_to_message' in msg:
- t = threading.Thread(target=saturatee)
- t.start()
- else:
- bot.sendMessage(chat_id, "Please respond to a photo.")
- def toggle():
- if "True" in open(str(chat_id) + "/data/jokes.txt", "r"):
- Jks = "*On*"
- if "False" in open(str(chat_id) + "/data/jokes.txt", "r"):
- Jks = "*Off*"
- if "True" in open(str(chat_id) + "/data/8ball.txt", "r"):
- eB = "*On*"
- if "False" in open(str(chat_id) + "/data/8ball.txt", "r"):
- eB = "*Off*"
- if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
- rL = "*On*"
- if "False" in open(str(chat_id) + "/data/roll.txt", "r"):
- rL = "*Off*"
- if "True" in open(str(chat_id) + "/data/lock.txt", "r"):
- gL = "*On*"
- if "False" in open(str(chat_id) + "/data/lock.txt", "r"):
- gL = "*Off*"
- if "False" in open(str(chat_id) + "/data/link.txt", "r"):
- nolink = "*Off*"
- if "True" in open(str(chat_id) + "/data/link.txt", "r"):
- nolink = "*On*"
- if "True" in open(str(chat_id) + "/data/pong.txt", "r"):
- pL = "*On*"
- if "False" in open(str(chat_id) + "/data/pong.txt", "r"):
- pL = "*Off*"
- if "True" in open(str(chat_id) + "/data/mm.txt", "r"):
- mL = "*On*"
- if "False" in open(str(chat_id) + "/data/mm.txt", "r"):
- mL = "*Off*"
- if "True" in open(str(chat_id) + "/data/antibot.txt", "r"):
- aB = "*On*"
- if "False" in open(str(chat_id) + "/data/antibot.txt", "r"):
- aB = "*Off*"
- if "True" in open(str(chat_id) + "/data/flip.txt", "r"):
- fL = "*On*"
- if "False" in open(str(chat_id) + "/data/flip.txt", "r"):
- fL = "*Off*"
- if "True" in open(str(chat_id) + "/data/tts.txt", "r"):
- tTS = "*On*"
- if "False" in open(str(chat_id) + "/data/tts.txt", "r"):
- tTS = "*Off*"
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- pT = "*On*"
- if "False" in open(str(chat_id) + "/data/photo.txt", "r"):
- pT = "*Off*"
- if "True" in open(str(chat_id) + "/data/urban.txt", "r"):
- uD = "*Off*"
- if "False" in open(str(chat_id) + "/data/urban.txt", "r"):
- uD = "*On*"
- bot.sendMessage(chat_id,
- "Jokes: " + Jks + "\nMagic 8Ball: " + eB + "\nRolling: " + rL + "\nInvite Links: " + nolink + "\nGroup Lock: " + gL + "\nAntibot: " + aB + "\nPhoto edit: " + pT + '\nUrban Dict: ' + uD + '\nTTS: ' + tTS, parse_mode='markdown')
- def roll2():
- edited = telepot.message_identifier(bot.sendMessage(chat_id, 'Rolling two dice...'))
- time.sleep(0.7)
- rollrandom = str(random.randint(1, 6))
- rollrandom2 = str(random.randint(1, 6))
- bot.editMessageText(edited, "*" + str(rollrandom) + "* and a", parse_mode="markdown")
- time.sleep(0.5)
- bot.editMessageText(edited, "*" + str(rollrandom) + "*" + " and a " + "*" + str(rollrandom2) + "*",
- parse_mode="markdown")
- def roll1():
- edited = telepot.message_identifier(bot.sendMessage(chat_id, 'Rolling a single dice'))
- time.sleep(0.7)
- bot.editMessageText(edited, "*" + str(random.randint(1, 6)) + "*", parse_mode="markdown")
- if message == "/roll":
- if isPrivateMessage == True:
- t = threading.Thread(target=roll1)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
- t = threading.Thread(target=roll1)
- t.start()
- if "/roll2" in message:
- if isPrivateMessage == True:
- if 'help' in message:
- pass
- else:
- t = threading.Thread(target=roll1)
- t.start()
- else:
- if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
- t = threading.Thread(target=roll1)
- t.start()
- if "/id" in message:
- try:
- bot.sendMessage(chat_id, msg['reply_to_message']['from']['id'])
- except:
- bot.sendMessage(chat_id, messageFromID)
- if "/chatid" in message:
- bot.sendMessage(chat_id, chat_id)
- if "/com" in message:
- if isPrivateMessage == True:
- bot.sendMessage(chat_id, '''*Admin/Group Commands:*\n\u2022/leaderboard\n\u2022/kick\n\u2022/kickme\n\u2022/ban\n\u2022/scramble\n\u2022/unban\n\u2022/mute\n\u2022/unmute\n\u2022/link\n\u2022/addcom\n\u2022/delcom\n\u2022/unrestrict\n\u2022/voice\n\u2022/arabic\n\u2022/blacklist\n\u2022/nomedia\n\u2022/lock\n\u2022/antibot\n\u2022/gt\n\u2022/eb\n\u2022/photo\n\u2022/jt\n\u2022/rt\n\u2022/toggles\n\u2022/pin\n\u2022/color (/colour)\n\u2022/greet\n\u2022/title\n\u2022/limit\n\u2022/promote\n\u2022/demote\n\u2022/warn\n\u2022/reset\n\n*Universal commands (works in group and pm):*\n\u2022/bw\n\u2022/swirl\n\u2022/saturate\n\u2022/play\n\u2022/tts\n\u2022/caption\n\u2022/captionb\n\u2022/jokes\n\u2022/time\n\u2022/totalmessages\n\u2022/ud\n\u2022/callme\n\u2022/8ball\n\u2022/polaroid\n\u2022/sharpen\n\u2022/posterize\n\u2022/invert\n\u2022/contour\n\u2022/rblur\n\u2022/blur\n\n_if you need help on a command, type the command and then help after (/bw help) Note: A lot of the commands don't have a help response YET, sorry!_''', parse_mode='markdown')
- else:
- bot.sendMessage(chat_id, "To view the list of commands, please use this command in PMs. It's a long list.")
- if message == "/kickme":
- try:
- bot.kickChatMember(chat_id, messageFromID)
- bot.unbanChatMember(chat_id, messageFromID)
- except:
- pass
- def executeCommand():
- customCommand = str(open(str(chat_id) + "/data/c" + str(message).replace("/", "slas12") + ".txt", "r").read())
- if os.path.isfile(str(chat_id) + '/data/counting' + str(message).replace("/", "slas12") + '.txt') == True:
- minus = int(str(open(str(chat_id) + '/data/counting' + str(message).replace('/', 'slas12') + '.txt', "r+").readlines()).replace("[", "").replace("'",
- "").replace(
- "]", "")) + 1
- open(chat_id + '/data/counting' + str(message).replace('/', 'slas12') + '.txt', "w").write(str(minus))
- counter = str(open(str(chat_id) + '/data/counting' + str(message).replace('/', 'slas12') + '.txt', 'r').read())
- else:
- counter = ""
- randomUser = 'soon'
- if 'reply_to_message' in msg:
- if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == False:
- repliedName = str(msg['reply_to_message']['from']['first_name'][:15])
- else:
- repliedName = str(open("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt").read())
- if 'username' in msg['reply_to_message']['from']:
- repliedUsername = "@" + str(msg['reply_to_message']['from']['username'])
- else:
- repliedUsername = '@None'
- else:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- repliedName = str(msg['from']['first_name'][:15])
- else:
- repliedName = str(open("data/n" + str(messageFromID) + ".txt").read())
- if 'username' in msg['from']:
- repliedUsername = "@" + str(msg['from']['username'])
- else:
- repliedUsername = '@None'
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- owningName = str(msg['from']['first_name'][:15])
- else:
- owningName = str(open("data/n" + str(messageFromID) + ".txt").read())
- if 'username' in msg['from']:
- owningUsername = str(msg['from']['username'])
- else:
- owningUsername = '@None'
- workedOut = str(customCommand).replace('$n', str(owningName)).replace('$u', str(owningUsername)).replace('$rn',
- repliedName).replace(
- '$ru', str(repliedUsername)).replace('$admin', '').replace('$c', str(counter))
- if '$admin' in customCommand:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, str(workedOut), parse_mode='markdown')
- else:
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt", "r").read():
- bot.sendMessage(chat_id, str(workedOut), parse_mode='markdown')
- else:
- bot.sendMessage(chat_id, str(workedOut), parse_mode='markdown')
- #if os.path.isfile(str(chat_id) + "/data/c" + str(message).replace("/", "slas12") + ".txt") == True:
- # stickerExecute = False
- # t = threading.Thread(target=executeCommand)
- # t.start()
- if '/permaban' in message:
- bot.sendMessage(chat_id, "Don't worry! @spoon is working on this right now, just give it time.")
- def admincom():
- if "/color" in message:
- if "green" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("green")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to green.")
- elif "red" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("red")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to red.")
- elif "blue" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("blue")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to blue.")
- elif "black" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("black")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
- bot.sendMessage(chat_id, "Color set to black.")
- elif "white" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("white")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to white.")
- elif "orange" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("orange")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to orange.")
- elif "yellow" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to yellow.")
- elif "gold" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to gold.")
- elif "pink" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("pink")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Color set to pink.")
- elif "purple" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("purple")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
- bot.sendMessage(chat_id, "Color set to purple.")
- if "/colour" in message:
- if "green" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("green")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to green.")
- elif "red" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("red")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to red.")
- elif "blue" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("blue")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to blue.")
- elif "black" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("black")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
- bot.sendMessage(chat_id, "Colour set to black.")
- elif "white" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("white")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to white.")
- elif "orange" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("orange")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to orange.")
- elif "yellow" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to yellow.")
- elif "gold" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("yellow")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to gold.")
- elif "pink" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("pink")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("black")
- bot.sendMessage(chat_id, "Colour set to pink.")
- elif "purple" in message:
- open(str(chat_id) + "/data/imagecolor.txt", "w").write("purple")
- open(str(chat_id) + "/data/textcolor.txt", "w").write("white")
- bot.sendMessage(chat_id, "Colour set to purple.")
- if message.startswith('/addcom '):
- if os.path.isfile(str(chat_id) + "/data/c" + str(message[8:]) + ".txt") == False:
- if "/" in message[8:]:
- command = message[8:].replace("/", "slas12")
- else:
- command = message[8:]
- open(str(chat_id) + "/data/c" + str(command).split("::")[0] + ".txt", "w").write("")
- open(str(chat_id) + "/data/commandlist.txt", "a").write(str(command) + "\n")
- open(str(chat_id) + "/data/c" + str(command).split("::")[0] + ".txt", "w").write(str(msg['text'][8:]).split("::")[1])
- if '$c' in str(msg['text']):
- open(str(chat_id) + '/data/counting' + str(command).split('::')[0] + '.txt', 'w').write('0')
- bot.sendMessage(chat_id, "Command added.")
- else:
- bot.sendMessage(chat_id, "This command is already added.")
- if message == "/addcom":
- bot.sendMessage(chat_id, "Example: /addcom /punch::$rn has been punched by $n!\n`spoon has been punched by fork!`\n\nSeperate with ::\n$u = senders username\n$ru = replied user's username (falls back to sender username)\n$n = senders name\n$rn = replied user's name (fallback)\n$c = a counter that adds 1 every time your command is used\n$admin = makes it an admin only command (put this anywhere after the ::, it'll be removed after the fact)", parse_mode='markdown')
- if "/delcom " in message:
- if os.path.isfile(str(chat_id) + "/data/c" + str(message[8:]).replace("/", "slas12") + ".txt") == True:
- os.remove(str(chat_id) + "/data/c" + str(message[8:]).replace("/", "slas12") + ".txt")
- with open(str(chat_id) + "/data/commandlist.txt", "r+") as f:
- t = f.read()
- f.seek(0)
- for line in t.split('\n'):
- if line != str(str(message[8:]).replace("/", "slas12").lower()):
- f.write(line + '\n')
- f.truncate()
- bot.sendMessage(chat_id, "Command deleted.")
- else:
- bot.sendMessage(chat_id, "This command is not added.")
- if "/limit " in message:
- if re.search('[a-zA-Z]', message[7:]):
- bot.sendMessage(chat_id, "The time limit can not be a letter.")
- else:
- open(str(chat_id) + "/data/gamelimit.txt", "w").write(message[7:])
- bot.sendMessage(chat_id, "Game time limit set to " + message[7:] + " second(s)")
- if "/admincom" in message:
- bot.sendMessage(chat_id, "Admin Commands:\n/greet (change greet type)\n/limit (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/limit (Set's game time limit)")
- if "/end" in message:
- if "inprogress" in open(str(chat_id) + "/data/scramble.txt", "r").read():
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + " reset the game. The word was " + open(
- str(chat_id) + "/data/word.txt", "r").read())
- open(str(chat_id) + "/data/scramble.txt", "w").write("False")
- if "inprogress" in open(str(chat_id) + "/data/state.txt", "r").read():
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + " reset the game. The state was " + open(
- str(chat_id) + "/data/statename.txt", "r").read())
- open(str(chat_id) + "/data/state.txt", "w").write("False")
- if "inprogress" in open(str(chat_id) + "/data/type.txt", "r").read():
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + " reset the game. The word was " + open(
- str(chat_id) + "/data/typeword.txt", "r").read())
- open(str(chat_id) + "/data/type.txt", "w").write("False")
- def dell():
- print(messageID)
- if 'reply_to_message' in msg:
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id,
- message_id=msg['reply_to_message']['message_id'])
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
- else:
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
- def dell2():
- bot.sendMessage(chat_id, 'Deleting all of this users messages...')
- with open(str(chat_id) + '/messages/msgid' + str(msg['reply_to_message']['from']['id']) + '.dat', 'r') as f:
- for line in reversed(list(f)):
- try:
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=line)
- except:
- pass
- if 'str' in line:
- open(str(chat_id) + '/messages/msgid' + str(msg['reply_to_message']['from']['id']) + '.dat',
- 'w').write("")
- break
- #telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
- open(str(chat_id) + '/messages/msgid' + str(msg['reply_to_message']['from']['id']) + '.dat',
- 'w').write("")
- if message.startswith("/del"):
- if message.startswith("/delcom"):
- ()
- elif message.startswith('/delall'):
- pass
- else:
- t = threading.Thread(target=dell)
- t.start()
- if message.startswith("/delall"):
- if message.startswith("/delcom"):
- ()
- else:
- t = threading.Thread(target=dell2)
- t.start()
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- if "/promote" in message:
- if msg['reply_to_message']['from']['id'] == botID:
- bot.sendMessage(chat_id, "Uhh I don't need to be admin of myself lol")
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id,
- "You're admin of the group, you already have access to my commands.")
- else:
- if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt").read():
- bot.sendMessage(chat_id, usersName + " is already an admin. To demote, type /demote")
- else:
- open(str(chat_id) + "/data/admin.txt", "a").write(str(msg['reply_to_message']['from']['id']) + "\n")
- bot.sendMessage(chat_id, str(msg['reply_to_message']['from']['first_name']) + " has been promoted")
- if "/demote" in message:
- print(str(chat_id) + '/data/admin.txt')
- if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt").read():
- with open(str(chat_id) + "/data/admin.txt", "r+") as f:
- t = f.read()
- f.seek(0)
- for line in t.split('\n'):
- if line != str(msg['reply_to_message']['from']['id']):
- f.write(line + '\n')
- f.truncate()
- bot.sendMessage(chat_id, usersName + " has been demoted.")
- else:
- bot.sendMessage(chat_id, usersName + " isn't promoted.")
- def bantimer():
- timer = int(str(open(str(chat_id) + "/data/bantimer" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read())) * 60
- time.sleep(timer)
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- bot.sendMessage(chat_id, usersName + " has been unbanned.", reply_to_message_id=msg['message_id'])
- bot.unbanChatMember(chat_id, msg['reply_to_message']['from']['id'])
- if message.startswith('/unblacklist '):
- bot.sendMessage(chat_id, 'Word removed from list!')
- f = open(str(chat_id) + '/data/blacklisted.txt', 'r')
- read = f.readlines()
- f.close()
- name = str(msg['text'].lower()[13:])
- newfile = """"""
- for i in read:
- if name in i:
- pass
- else:
- newfile += i
- n = open(str(chat_id) + '/data/blacklisted.txt', 'w')
- one = str(newfile)
- n.write(one)
- n.close()
- if message.startswith('/blacklist '):
- blacklistedWord = msg['text'].lower()[11:]
- if 'the' == blacklistedWord:
- bot.sendMessage(chat_id, 'That is unreasonable.')
- elif 'this' == blacklistedWord:
- bot.sendMessage(chat_id, 'That is unreasonable.')
- elif 'there' == blacklistedWord:
- bot.sendMessage(chat_id, 'That is unreasonable.')
- elif 'is' == blacklistedWord:
- bot.sendMessage(chat_id, 'That is unreasonable.')
- elif 'that' == blacklistedWord:
- bot.sendMessage(chat_id, 'That is unreasonable.')
- else:
- open(str(chat_id) + "/data/blacklisted.txt", "a").write(str(blacklistedWord) + '\n')
- bot.sendMessage(chat_id, 'Word has been blacklisted. If this word is used, the message will be deleted, and the user will be kicked. /unblacklist to remove words.')
- def banusername():
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][5:]:
- word = str(msg['text'][5:]).replace('@', "").lower()
- else:
- word = str(msg['text'][5:]).lower()
- # iterate over lines, and print out line numbers which contain
- # the word of interest.
- for i, line in enumerate(lines):
- if word in line.lower(): # or word in line.split() to search for full words
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- lines[i].split(">:>")[0]
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, '@' + word + ' has been banned by ' + ownerName)
- bot.kickChatMember(chat_id, int(lines[i].split('>:>')[0]))
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
- break
- else:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been banned.')
- bot.kickChatMember(chat_id, int(lines[i].split('>:>')[0]))
- #with open("data/listofusers.data", 'rw') as file:
- # for line in file:
- # if not line.isspace():
- # file.write(line)
- def kickusername():
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][6:]:
- word = str(msg['text'][6:]).replace('@', "")
- else:
- word = str(msg['text'][6:])
- for i, line in enumerate(lines):
- if word in line.lower():
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- lines[i].split(">:>")[0]
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't kick admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, '@' + word + ' has been kicked by ' + ownerName)
- bot.kickChatMember(chat_id, int(lines[i].split('>:>')[0]))
- bot.unbanChatMember(chat_id, int(lines[i].split('>:>')[0]))
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't kick admins. Sorry!")
- break
- else:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been kicked by ' + ownerName)
- bot.kickChatMember(chat_id, int(lines[i].split('>:>')[0]))
- bot.unbanChatMember(chat_id, int(lines[i].split('>:>')[0]))
- # with open("data/listofusers.data", 'rw') as file:
- # for line in file:
- # if not line.isspace():
- # file.write(line)
- def unmuteusername():
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][8:]:
- word = str(msg['text'][8:]).replace('@', "")
- else:
- word = str(msg['text'][8:])
- for i, line in enumerate(lines):
- if word in line.lower():
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- lines[i].split(">:>")[0]
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- try:
- bot.sendMessage(chat_id, '@' + word + ' has been unmuted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- except:
- bot.sendMessage(chat_id, "I can't unmute admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, '@' + word + ' has been unmuted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- try:
- bot.sendMessage(chat_id, usersName + ' has been unmuted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- except:
- bot.sendMessage(chat_id, "I can't unmute admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, usersName + ' has been unmuted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- # with open("data/listofusers.data", 'rw') as file:
- # for line in file:
- # if not line.isspace():
- # file.write(line)
- def muteusername():
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- if '@' in msg['text'][6:]:
- word = str(msg['text'][6:]).replace('@', "")
- else:
- word = str(msg['text'][6:])
- for i, line in enumerate(lines):
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- lines[i].split(">:>")[0]
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- bot.sendMessage(chat_id, "I can't mute admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, '@' + word + ' has been muted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=False,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- try:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been unmuted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- except:
- bot.sendMessage(chat_id, "I can't unmute admins, Sorry!")
- break
- else:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been muted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),
- can_send_messages=False,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- # with open("data/listofusers.data", 'rw') as file:
- # for line in file:
- # if not line.isspace():
- # file.write(line)
- def nomediausername():
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][9:]:
- word = str(msg['text'][9:]).replace('@', "")
- else:
- word = str(msg['text'][9:])
- for i, line in enumerate(lines):
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- lines[i].split(">:>")[0]
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- try:
- bot.sendMessage(chat_id, '@' + word + ' has been muted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]), can_send_messages=True,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- except:
- bot.sendMessage(chat_id, "I can't mute admins. Sorry!")
- break
- elif str(lines[i].split(">:>")[0]) in open(str(chat_id) + "/data/admin.txt",
- "r").read():
- bot.sendMessage(chat_id, "I can't mute admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, '@' + word + ' has been muted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),can_send_messages=True,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- try:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- usersName = str(lines[i].split(">:>")[1])
- else:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(msg['from']['id']) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been muted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]), can_send_messages=True,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- except:
- bot.sendMessage(chat_id, "I can't mute admins. Sorry!")
- break
- elif str(lines[i].split(">:>")[0]) in open(str(chat_id) + "/data/admin.txt",
- "r").read():
- bot.sendMessage(chat_id, "I can't mute admins. Sorry!")
- break
- else:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been muted by ' + ownerName)
- bot.restrictChatMember(chat_id, int(lines[i].split(">:>")[0]),can_send_messages=True,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- # with open("data/listofusers.data", 'rw') as file:
- # for line in file:
- # if not line.isspace():
- # file.write(line)
- def unbanusername():
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][7:]:
- word = str(msg['text'][7:]).replace('@', "")
- else:
- word = str(msg['text'][7:])
- # iterate over lines, and print out line numbers which contain
- # the word of interest.
- for i, line in enumerate(lines):
- if word in line.lower(): # or word in line.split() to search for full words
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- lines[i].split(">:>")[0]
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- #bot.sendMessage(chat_id, "I can't unban admins. Sorry!")
- break
- elif str(lines[i].split(">:>")[0]) in open(str(chat_id) + "/data/admin.txt",
- "r").read():
- #bot.sendMessage(chat_id, "I can't unban admins. Sorry!")
- break
- else:
- bot.sendMessage(chat_id, '@' + word + ' has been unbanned by ' + ownerName)
- bot.unbanChatMember(chat_id, int(lines[i].split('>:>')[0]))
- else:
- if bot.getChatMember(chat_id, int(lines[i].split(">:>")[0])) in bot.getChatAdministrators(
- chat_id):
- #bot.sendMessage(chat_id, "I can't unban admins. Sorry!")
- break
- elif str(lines[i].split(">:>")[0]) in open(str(chat_id) + "/data/admin.txt",
- "r").read():
- #bot.sendMessage(chat_id, "I can't unban admins. Sorry!")
- break
- else:
- usersName = str(open("data/n" + str(lines[i].split(">:>")[0]) + ".txt").read())
- if os.path.isfile("data/n" + str(lines[i].split(">:>")[0]) + ".txt") == False:
- ownerName = str(msg['from']['first_name'])
- else:
- ownerName = str(open("data/n" + str(msg['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, usersName + ' has been unbanned by ' + ownerName)
- bot.unbanChatMember(chat_id, int(lines[i].split('>:>')[0]))
- # with open("data/listofusers.data", 'rw') as file:
- # for line in file:
- # if not line.isspace():
- # file.write(line)
- if "/ban " in message:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- if 'reply_to_message' in msg:
- if msg['reply_to_message']['from']['id'] != messageFromID:
- if "-" in message[5:]:
- bot.sendMessage(chat_id, "lol nice try")
- else:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
- elif str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt", "r").read():
- bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
- else:
- if re.search('[a-zA-Z]', message[5:]):
- bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
- bot.sendMessage(chat_id,
- msg['reply_to_message']['from']['first_name'] + " has been banned by " +
- msg['from']['first_name'] + ".")
- else:
- if int(str(message[5:])) > 10081:
- bot.sendMessage(chat_id, "Cannot ban a person for more than a week.")
- else:
- t = threading.Thread(target=bantimer)
- t.start()
- open(str(chat_id) + "/data/bantimer" + str(msg['reply_to_message']['from']['id']) + ".txt", "w").write(
- str(message[5:]))
- bot.sendMessage(chat_id, usersName + " has been banned for " + str(message[5:]) + " minute(s).", reply_to_message_id=msg['message_id'])
- bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
- else:
- if re.search('[a-zA-Z]', message[5:]):
- if '@' in str(msg['text'][5:]):
- t = threading.Thread(target=banusername)
- t.start()
- else:
- ()
- if message == '/ban':
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
- else:
- if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt", "r").read():
- bot.sendMessage(chat_id, "I can't ban admins. Sorry!")
- else:
- bot.sendMessage(chat_id, msg['reply_to_message']['from']['first_name'] + " has been banned by " +
- msg['from']['first_name'] + ".")
- open(str(chat_id) + "/data/unban.txt", "w").write(
- str(msg['reply_to_message']['from']['id']))
- global banned
- bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
- else:
- ()
- if message == '/mute':
- if 'reply_to_message' in msg:
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=False,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- bot.sendMessage(chat_id, usersName + " has been muted.", reply_to_message_id=msg['message_id'])
- else:
- if '@' in msg['text']:
- t = threading.Thread(target=muteusername)
- t.start()
- def mutetimer():
- timer = int(str(open(str(chat_id) + "/data/mutetimer" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read())) * 60
- time.sleep(timer)
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- bot.sendMessage(chat_id, usersName + " has been unmuted.", reply_to_message_id=msg['message_id'])
- if "/mute " in message:
- if 'reply_to_message' in msg:
- if msg['reply_to_message']['from']['id'] != messageFromID:
- if "-" in message[6:]:
- bot.sendMessage(chat_id, "lol nice try")
- else:
- if re.search('[a-zA-Z]', message[6:]):
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=False,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- bot.sendMessage(chat_id, usersName + " has been muted.", reply_to_message_id=msg['message_id'])
- else:
- if int(str(message[6:])) > 10081:
- bot.sendMessage(chat_id, "Cannot mute a person for more than a week.")
- else:
- t = threading.Thread(target=mutetimer)
- t.start()
- open(str(chat_id) + "/data/mutetimer" + str(msg['reply_to_message']['from']['id']) + ".txt", "w").write(
- str(message[6:]))
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'],
- can_send_messages=False,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- bot.sendMessage(chat_id, usersName + " has been muted for " + str(message[6:]) + " minute(s).", reply_to_message_id=msg['message_id'])
- else:
- if '@' in msg['text']:
- t = threading.Thread(target=muteusername)
- t.start()
- if "/unmute" in message:
- if 'reply_to_message' in msg:
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- bot.sendMessage(chat_id, usersName + " has been unmuted.", reply_to_message_id=msg['message_id'])
- else:
- if '@' in msg['text']:
- t = threading.Thread(target=unmuteusername)
- t.start()
- if "/nomedia" in message:
- if 'reply_to_message' in msg:
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=True,
- can_add_web_page_previews=False, can_send_media_messages=False,
- can_send_other_messages=False)
- bot.sendMessage(chat_id, usersName + " has restricted media.", reply_to_message_id=msg['message_id'])
- else:
- if '@' in msg['text']:
- t = threading.Thread(target=nomediausername)
- t.start()
- if "/unrestrict" in message:
- bot.restrictChatMember(chat_id, msg['reply_to_message']['from']['id'], can_send_messages=True,
- can_add_web_page_previews=True, can_send_media_messages=True,
- can_send_other_messages=True)
- bot.sendMessage(chat_id, usersName + " has been unrestricted.", reply_to_message_id=msg['message_id'])
- if "/unban" in message:
- if str(botID) in str(unique_lines.keys()):
- if 'reply_to_message' in msg:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't unban admins. Sorry!")
- else:
- bot.sendMessage(chat_id, "User has been unbanned")
- open(str(chat_id) + "/data/unban.txt", "w").write(
- str(msg['reply_to_message']['from']['id']))
- global banned
- bot.unbanChatMember(chat_id, msg['reply_to_message']['from']['id'])
- else:
- ()
- #if '@' in msg['text']:
- # t = threading.Thread(target=unbanusername)
- # t.start()
- else:
- bot.sendMessage(chat_id, "Error: I need to be admin.")
- if "/unban " in message:
- if str(botID) in str(unique_lines.keys()):
- if 'reply_to_message' in msg:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't unban admins. Sorry!")
- else:
- bot.sendMessage(chat_id, "User has been unbanned")
- open(str(chat_id) + "/data/unban.txt", "w").write(
- str(msg['reply_to_message']['from']['id']))
- global banned
- bot.unbanChatMember(chat_id, msg['reply_to_message']['from']['id'])
- elif '@' in msg['text']:
- t = threading.Thread(target=unbanusername)
- t.start()
- else:
- bot.sendMessage(chat_id, "Error: I need to be admin.")
- if "/kick" in message:
- if str(botID) in str(unique_lines.keys()):
- if 'reply_to_message' in msg:
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "I can't kick admins. Sorry!")
- else:
- if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt", "r").read():
- bot.sendMessage(chat_id, "I can't kick admins. Sorry!")
- else:
- bot.sendMessage(chat_id,
- msg['reply_to_message']['from']['first_name'] + " has been kicked by " +
- msg['from'][
- 'first_name'] + ".")
- bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
- bot.unbanChatMember(chat_id, msg['reply_to_message']['from']['id'])
- elif '@' in msg['text']:
- t = threading.Thread(target=kickusername)
- t.start()
- if isPrivateMessage == False:
- if message.startswith("/title"):
- try:
- bot.setChatTitle(chat_id, str(msg['text'][7:]))
- except:
- bot.sendMessage(chat_id, "An error has occurred")
- if "/byebot" in message:
- bot.sendMessage(chat_id, "Bye! If you had any issues, contact @spoon. Thanks!")
- bot.leaveChat(chat_id)
- else:
- bot.sendMessage(chat_id, "Sorry.. I will leave you alone :( PM whenever")
- if isPrivateMessage == False:
- if "/warn" in message:
- if str(botID) in str(unique_lines.keys()):
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- bot.sendMessage(chat_id, "Admins can not get warned.")
- else:
- if os.path.isfile(str(chat_id) + "/data/" + str(
- msg['reply_to_message']['from']['id']) + ".txt") == False:
- filet = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "w")
- filew = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt")
- filer = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r")
- filee = open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r+")
- filet.write("1")
- bot.sendMessage(chat_id, usersName + " has been warned by " + str(msg['from']['first_name']) + " *(1/3)*", parse_mode="markdown")
- open("data/temp.txt", "w").write(str(msg['reply_to_message']['from']['id']))
- global warnd
- else:
- if "1" in open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r"):
- open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "w").write(
- "2")
- bot.sendMessage(chat_id, usersName + "has been warned by " + str(
- msg['from']['first_name']) + " *(2/3)*", parse_mode="markdown")
- open(str(chat_id) + "/data/temp.txt", "w").write(str(msg['reply_to_message']['from']['id']))
- elif "2" in open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r"):
- open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt", "w").write(
- "3")
- bot.sendMessage(chat_id, "You exceeded warn limit, you are now banned. *(3/3)*",
- parse_mode="markdown")
- bot.kickChatMember(chat_id, msg['reply_to_message']['from']['id'])
- os.remove(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt")
- open(str(chat_id) + "/data/temp.txt", "w").write(str(msg['reply_to_message']['from']['id']))
- if "/photo" in message:
- if 'http' in message:
- pass
- else:
- if "True" in open(str(chat_id) + "/data/photo.txt", "r"):
- open(str(chat_id) + "/data/photo.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer edit photos")
- else:
- open(str(chat_id) + "/data/photo.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now edit photos")
- if "/wel " in message:
- if "Photo" in open(str(chat_id) + "/data/greet.txt", "r"):
- if len(msg['text'][5:]) > 15:
- bot.sendMessage(chat_id, "This message is too long for a picture message, please try again. Or switch to text by typing /greet")
- else:
- open(str(chat_id) + "/data/greettext.txt", "w").write(msg['text'][5:])
- bot.sendMessage(chat_id, "Welcome message set!")
- else:
- if "True" in open(str(chat_id) + "/wel.txt").read():
- open(str(chat_id) + "/welcome.txt", "w").write(msg['text'][5:])
- bot.sendMessage(chat_id, "Welcome message set!")
- else:
- bot.sendMessage(chat_id, "Welcome messages have been disabled. To re-enable them, type /wt")
- if "/pin" in message:
- if 'reply_to_message' in msg:
- bot.pinChatMessage(chat_id, msg['reply_to_message']['message_id'],
- disable_notification=True)
- telegram.Bot.deleteMessage(self=Bot, chat_id=chat_id, message_id=messageID)
- else:
- bot.sendMessage(chat_id, "Reply to message.")
- if "/wt" in message:
- if "True" in open(str(chat_id) + "/wel.txt", "r"):
- open(str(chat_id) + "/wel.txt", "w").write("False")
- bot.sendMessage(chat_id, "Welcome messages have been disabled.")
- else:
- open(str(chat_id) + "/wel.txt", "w").write("True")
- bot.sendMessage(chat_id, "Welcome messages have been enabled.")
- if "/gt" in message:
- if "True" in open(str(chat_id) + "/data/games.txt", "r"):
- open(str(chat_id) + "/data/games.txt", "w").write("False")
- bot.sendMessage(chat_id, "Games have been disabled.")
- else:
- open(str(chat_id) + "/data/games.txt", "w").write("True")
- bot.sendMessage(chat_id, "Games have been enabled.")
- if "/rt" in message:
- if "True" in open(str(chat_id) + "/data/roll.txt", "r"):
- open(str(chat_id) + "/data/roll.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer roll dice.")
- else:
- open(str(chat_id) + "/data/roll.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now roll dice.")
- if "/link" in message:
- if "True" in open(str(chat_id) + "/data/link.txt", "r"):
- open(str(chat_id) + "/data/link.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer remove invite links.")
- else:
- open(str(chat_id) + "/data/link.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now remove invite links.")
- if "/jt" in message:
- if "True" in open(str(chat_id) + "/data/jokes.txt", "r"):
- open(str(chat_id) + "/data/jokes.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer tell jokes.")
- else:
- open(str(chat_id) + "/data/jokes.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now tell jokes.")
- if "/eb" in message:
- if "True" in open(str(chat_id) + "/data/8ball.txt", "r"):
- open(str(chat_id) + "/data/8ball.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer answer questions.")
- else:
- open(str(chat_id) + "/data/8ball.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now answer questions.")
- if "/spam" in message:
- if "True" in open(str(chat_id) + "/data/spam.txt", "r"):
- open(str(chat_id) + "/data/spam.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer restrict spamming.")
- else:
- open(str(chat_id) + "/data/spam.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now restrict spamming.")
- if "/setpref " in message:
- open(str(chat_id) + "/data/compref.txt", "w").write(str(msg['text'])[9:])
- bot.sendMessage(chat_id, "I will now respond to '" + str(open(str(chat_id)) + '/data/compref.txt', 'r').read() + "' (" + str(open(str(chat_id + '/data/compref.txt, 'r''))) + 'kick)')
- if "/voice" in message:
- if "True" in open(str(chat_id) + "/data/tts.txt", "r"):
- open(str(chat_id) + "/data/tts.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer speak words.")
- else:
- open(str(chat_id) + "/data/tts.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now speak words.")
- if "/urbandict" in message:
- if "True" in open(str(chat_id) + "/data/urban.txt", "r"):
- open(str(chat_id) + "/data/urban.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will now define words from UD.")
- else:
- open(str(chat_id) + "/data/urban.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will no longer define words from UD.")
- if "/lb" in message:
- if "True" in open(str(chat_id) + "/data/leaderboard.txt", "r"):
- open(str(chat_id) + "/data/leaderboard.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer display the leaderboard.")
- else:
- open(str(chat_id) + "/data/leaderboard.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now display the leaderboard.")
- if "/arabic" in message:
- if "True" in open(str(chat_id) + "/data/arabic.txt", "r"):
- open(str(chat_id) + "/data/arabic.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer restrict arabic.")
- else:
- open(str(chat_id) + "/data/arabic.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now restrict arabic.")
- if "/lock" in message:
- if "True" in open(str(chat_id) + "/data/lock.txt", "r"):
- open(str(chat_id) + "/data/lock.txt", "w").write("False")
- bot.sendMessage(chat_id, "The group is no longer locked.")
- else:
- open(str(chat_id) + "/data/lock.txt", "w").write("True")
- bot.sendMessage(chat_id, "The group is now locked, no one can join")
- if "/antibot" in message:
- if "True" in open(str(chat_id) + "/data/antibot.txt", "r"):
- open(str(chat_id) + "/data/antibot.txt", "w").write("False")
- bot.sendMessage(chat_id, "I will no longer kick bots.")
- else:
- open(str(chat_id) + "/data/antibot.txt", "w").write("True")
- bot.sendMessage(chat_id, "I will now kick bots.")
- if "/greet" in message:
- if "Text" in open(str(chat_id) + "/data/greet.txt", "r"):
- open(str(chat_id) + "/data/greet.txt", "w").write("Photo")
- bot.sendMessage(chat_id, "I will now greet with photo.")
- else:
- open(str(chat_id) + "/data/greet.txt", "w").write("Text")
- bot.sendMessage(chat_id, "I will now greet with text.")
- if message == "/wel":
- if "True" in open(str(chat_id) + "/wel.txt").read():
- bot.sendMessage(chat_id,"To set a message, type '/wel Welcome message.'\n$u = Username\n$n = User's name\n$t = Title")
- else:
- bot.sendMessage(chat_id, "Welcome messages have been disabled. To re-enable them, type /wt")
- if "/reset" in message:
- if str(botID) in str(unique_lines.keys()):
- if os.path.isfile(str(chat_id) + "/data/" + str(
- msg['reply_to_message']['from']['id']) + ".txt") == True:
- os.remove(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt")
- bot.sendMessage(chat_id, "Poof! All warns have been removed.")
- else:
- bot.sendMessage(chat_id, usersName + " has no warns.")
- if "/toggles" in message:
- t = threading.Thread(target=toggle)
- t.start()
- if "/give " in message:
- if 'username' in msg['from']:
- sender = "\n\u251c@" + str(msg['from']['username'])
- else:
- sender = ""
- if 'username' in msg['reply_to_message']['from']:
- receiver = "\n\u251c@" + str(msg['reply_to_message']['from']['username'])
- else:
- receiver = ""
- if "reply_to_message" in msg:
- if msg['reply_to_message']['from']['id'] != messageFromID:
- if "-" in message[6:]:
- bot.sendMessage(chat_id, "lol nice try")
- bot.sendMessage(374986841, "\U0001F3E6**Bank**\U0001F3E6\n\u250cSender \U0001F4E4\n\u251c" + str(
- msg['from']['first_name']) + sender + "\n\u251c" + str(
- open("rooms/" + str(msg['from']['id']) + "money.txt",
- "r").read()) + " coins\n\u251cSent " + str(msg['text'][6:]) + "\n\u2514" + str(
- msg['from']['id']) + "\n\n\u250cReceiver \U0001F4E5\n\u251c" + str(
- msg['reply_to_message']['from']['first_name']) + receiver + "\n\u251c" + str(
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + " coins\n\u2514" + str(msg['reply_to_message']['from'][
- 'id']) + "\n\n\u250cReceipt \U0001F4C3\n\u2514Success? \U0001F534",
- parse_mode="markdown", disable_notification=True)
- else:
- if re.search('[a-zA-Z]', message[6:]):
- print(
- str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", ""))
- bot.sendMessage(374986841,
- "\U0001F3E6**Bank**\U0001F3E6\n\u250cSender \U0001F4E4\n\u251c" + str(
- msg['from']['first_name']) + sender + "\n\u251c" + str(
- open("rooms/" + str(msg['from']['id']) + "money.txt",
- "r").read()) + "\n\u2514" + str(
- msg['from']['id']) + "\n\n\u250cReceiver \U0001F4E5\n\u251c" + str(
- msg['reply_to_message']['from'][
- 'first_name']) + receiver + "\n\u251c" + str(
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + " coins\n\u2514" + str(msg['reply_to_message']['from'][
- 'id']) + "\n\n\u250cReceipt \U0001F4C3\n\u251cSent " + str(
- msg['text'][6:]) + "\n\u2514Success? \U0001F534",
- parse_mode="markdown")
- else:
- if int(str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
- "[",
- "").replace(
- "'", "").replace("]", "")) == int(str(msg['text'][6:])):
- minus = int(
- str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
- "[",
- "").replace(
- "'", "").replace("]", "")) - int(str(msg['text'][6:]))
- add = int(
- str(open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").readlines()).replace("[", "").replace(
- "'", "").replace("]", "")) + int(message[6:])
- open("rooms/" + str(messageFromID) + "money.txt", "w").write("0")
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "w").write(
- str(add))
- bot.sendMessage(chat_id, "Sent *" + str(msg['text'][6:]) + "* coins!",
- parse_mode="markdown")
- bot.sendMessage(374986841,
- "\U0001F3E6**Bank**\U0001F3E6\n\u250cSender \U0001F4E4\n\u251c" + str(
- msg['from']['first_name']) + sender + "\n\u251c" + str(
- open("rooms/" + str(msg['from']['id']) + "money.txt",
- "r").read()) + "\n\u2514" + str(
- msg['from']['id']) + "\n\n\u250cReceiver \U0001F4E5\n\u251c" + str(
- msg['reply_to_message']['from'][
- 'first_name']) + receiver + "\n\u251c" + str(open(
- "rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + " coins\n\u2514" + str(msg['reply_to_message']['from'][
- 'id']) + "\n\n\u250cReceipt \U0001F4C3\n\u251cSent " + str(
- msg['text'][6:]) + "\n\u2514Success? \U0001F535",
- parse_mode="markdown")
- elif int(str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
- "[",
- "").replace(
- "'", "").replace("]", "")) > int(str(msg['text'][6:])):
- minus = int(
- str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace(
- "[",
- "").replace(
- "'", "").replace("]", "")) - int(str(msg['text'][6:]))
- add = int(
- str(open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").readlines()).replace("[", "").replace(
- "'", "").replace("]", "")) + int(message[6:])
- open("rooms/" + str(messageFromID) + "money.txt", "w").write(str(minus))
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "w").write(
- str(add))
- bot.sendMessage(chat_id, "Sent *" + str(msg['text'][6:]) + "* coins!",
- parse_mode="markdown")
- bot.sendMessage(374986841,
- "\U0001F3E6**Bank**\U0001F3E6\n\u250cSender \U0001F4E4\n\u251c" + str(
- msg['from']['first_name']) + sender + "\n\u251c" + str(
- open("rooms/" + str(msg['from']['id']) + "money.txt",
- "r").read()) + "\n\u2514" + str(
- msg['from']['id']) + "\n\n\u250cReceiver \U0001F4E5\n\u251c" + str(
- msg['reply_to_message']['from'][
- 'first_name']) + receiver + "\n\u251c" + str(open(
- "rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + " coins\n\u2514" + str(msg['reply_to_message']['from'][
- 'id']) + "\n\n\u250cReceipt \U0001F4C3\n\u251cSent " + str(
- msg['text'][6:]) + "\n\u2514Success? \U0001F535",
- parse_mode="markdown")
- else:
- bot.sendMessage(chat_id, "You don't have enough money.")
- bot.sendMessage(374986841,
- "\U0001F3E6**Bank**\U0001F3E6\n\u250cSender \U0001F4E4\n\u251c" + str(
- msg['from']['first_name']) + sender + "\n\u251c" + str(
- open("rooms/" + str(msg['from']['id']) + "money.txt",
- "r").read()) + "\n\u2514" + str(
- msg['from']['id']) + "\n\n\u250cReceiver \U0001F4E5\n\u251c" + str(
- msg['reply_to_message']['from'][
- 'first_name']) + receiver + "\n\u251c" + str(open(
- "rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + " coins\n\u2514" + str(msg['reply_to_message']['from'][
- 'id']) + "\n\n\u250cReceipt \U0001F4C3\n\u251cSent " + str(
- msg['text'][6:]) + "\n\u2514Success? \U0001F534",
- parse_mode="markdown")
- else:
- bot.sendMessage(chat_id, "lol nice try")
- if "/jokes" in message:
- if "True" in open(str(chat_id) + "/data/jokes.txt", "r"):
- bot.sendMessage(chat_id, random.choice(jokes))
- def place_value(number):
- return ("{:,}".format(number))
- def totalcoins():
- dir = '/home/*spoon/rooms/*money.txt'
- #dir = '/home/*spoon/Desktop/Coding/rooms/*money.txt'
- cv_img = []
- open('texting.txt', 'w').write('')
- open('data/totalcoins.txt', 'w').write('0')
- for img in glob.glob(dir):
- try:
- n = open(img, 'r').read()
- if os.path.isfile('data/totalcoins.txt') == False:
- open('data/totalcoins.txt', 'w').write(str(n))
- else:
- open('texting.txt', 'a+').write(n + ',')
- original = open('data/totalcoins.txt', 'r').readlines()
- minus = int(
- str(original).replace("[", "").replace("'", "").replace("]", "")) + int(str(n))
- open('data/totalcoins.txt',
- "w").write(
- str(minus))
- print(open('data/totalcoins.txt', 'r').read())
- cv_img.append(n)
- print(open('data/totalcoins.txt', 'r').read())
- except:
- pass
- bot.sendMessage(chat_id, 'There are a total of ' + place_value(int(str(open('data/totalcoins.txt', 'r').read()))) + ' coins.')
- def totalmessage():
- cv_img = []
- open('data/totalmessages' + str(msg['from']['id']) + '.txt', 'w').write('0')
- for img in glob.glob('/home/*spoon/*/messages/' + str(msg['from']['id']) + '.txt'):
- n = open(img, 'r').read()
- if os.path.isfile('data/totalmessages' + str(msg['from']['id']) + '.txt') == False:
- open('data/totalmessages' + str(msg['from']['id']) + '.txt', 'w').write(str(n))
- else:
- original = open('data/totalmessages' + str(msg['from']['id']) + '.txt', 'r').readlines()
- minus = int(
- str(original).replace("[", "").replace("'", "").replace("]", "")) + int(str(n))
- open('data/totalmessages' + str(msg['from']['id']) + '.txt',
- "w").write(
- str(minus))
- print(open('data/totalmessages' + str(msg['from']['id']) + '.txt', 'r').read())
- cv_img.append(n)
- print(open('data/totalmessages' + str(msg['from']['id']) + '.txt', 'r').read())
- bot.sendMessage(chat_id, 'You have sent a total of ' + place_value(int(str(open('data/totalmessages' + str(msg['from']['id']) + '.txt', 'r').read()))) + ' messages in all of the groups we share.')
- if '/totalmessages' in message:
- t = threading.Thread(target=totalmessage)
- t.start()
- if '/countcoin' in message:
- t = threading.Thread(target=totalcoins)
- t.start()
- def testing():
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- #font_file = 'NotoColorEmoji.ttf'
- #symbola_font = TTFont('Symbola', font_file)
- #pdfmetrics.registerFont(symbola_font)
- try:
- color = 'black'
- color1 = 'white'
- profiles = bot.getUserProfilePhotos(msg['from']['id'])
- file_id = profiles['photos'][0][-1]['file_id']
- filename = str(msg['from']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- im = Image.open(filename)
- img = PIL.Image.new("RGB", (640, 800), (color))
- draw = PIL.ImageDraw.Draw(img)
- font = ImageFont.truetype("comic.ttf", int("65"))
- except:
- filename = "NoPFP.jpg"
- im = Image.open(filename)
- img = Image.new("RGB", (640, 800), (color))
- draw = PIL.ImageDraw.Draw(img)
- font = ImageFont.truetype("comic.ttf", int("65"))
- if os.path.isfile("data/n" + str(msg['from']['id']) + ".txt") == False:
- if len(msg['from']['first_name']) > 15:
- line2 = msg['from']['first_name'][:15] + "...!"
- else:
- line2 = msg['from']['first_name'] + "!"
- else:
- if len(open("data/n" + str(msg['from']['id']) + ".txt").read()) > 15:
- line2 = open("data/n" + str(msg['from']['id']) + ".txt").read()[:15] + "...!"
- else:
- line2 = open("data/n" + str(msg['from']['id']) + ".txt").read() + "!"
- line1 = 'Welcome'
- w, h = font.getsize(line1)
- w2, h2 = font.getsize(line2)
- draw.text(((650 - w) / 2, (1360 - h) / 2), line1, font=font, fill=str(color1))
- draw.text(((650 - w2) / 2, ((1300 - h2) / 2) + 100), line2, font=font, fill=str(color1))
- img.paste(im, (0, 0))
- img.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove("1" + filename)
- if filename != "NoPFP.jpg":
- os.remove(filename)
- if '/megatest' in message:
- t = threading.Thread(target=testing)
- t.start()
- def define():
- if "False" in open(str(chat_id) + "/data/urban.txt", "r"):
- heart = u'\u2764'
- term = msg['text'][4:].lower()
- if term == "spoon":
- bot.sendMessage(chat_id, "The creator of this bot @spoon" + heart)
- elif term == "panda":
- bot.sendMessage(chat_id,
- "*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.",
- parse_mode="markdown")
- elif term == "alla":
- bot.sendMessage(chat_id,
- "*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.",
- parse_mode="markdown")
- elif term == "awais":
- bot.sendMessage(chat_id,
- "*Awais:*\n\nOne word. Telegod.",
- parse_mode="markdown")
- else:
- term = str(message.lower()[4:]).title()
- try:
- definition = urbandict.define(term)[0]['def']
- except:
- definition = urbandict.define(term)[0]['def']
- try:
- example1 = urbandict.define(term)[0]['example']
- except:
- example1 = 'None'
- try:
- example2 = urbandict.define(term)[1]['example']
- except:
- example2 = "None/"
- if len(example2) > 275:
- bot.sendMessage(chat_id, "*" + term + "*:\n\n" + definition + '\n\n_1.) ' + example1 + '_', parse_mode="markdown")
- else:
- bot.sendMessage(chat_id,
- "*" + term + "*:\n\n" + definition + '\n\n_1.) ' + example1 + '\n2.) ' + example2 + '_',
- parse_mode="markdown")
- if "/ud " in message:
- t = threading.Thread(target=define)
- term = msg['text'][4:]
- t.start()
- slapr = ['$q was split from crotch to sternum by $w.', "$q was busted.", '$q was exposed by $w.', "$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."]
- slap = ['$q was split from crotch to sternum.', "$q got exposed.", "$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."]
- if "/google " in message:
- google = msg['text'][8:]
- bot.sendMessage(chat_id, "[" + str(google) + "](https://www.google.com/#q=" + str(google).replace(" ",
- "+") + ")",
- parse_mode="markdown", disable_web_page_preview=True)
- if "/slap" in message:
- if "reply_to_message" in msg:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- name = str(msg['from']['first_name'])
- else:
- name = str(open("data/n" + str(messageFromID) + ".txt").read())
- if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == False:
- namer = str(msg['reply_to_message']['from']['first_name'])
- else:
- namer = str(open("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt").read())
- bot.sendMessage(chat_id, str(random.choice(slapr)).replace("$q", namer).replace("$w", name), reply_to_message_id=msg['message_id'])
- else:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- name = str(msg['from']['first_name'])
- else:
- name = str(open("data/n" + str(messageFromID) + ".txt").read())
- bot.sendMessage(chat_id, str(random.choice(slap)).replace("$q", name), reply_to_message_id=msg['message_id'])
- if message == '/def':
- bot.sendMessage(chat_id, "Usage: /def <term>")
- if messageType != 'private':
- if "/scramble" in message:
- if "True" in open(str(chat_id) + "/data/games.txt", "r").read():
- if "False" in open(str(chat_id) + "/data/scramble.txt", "r").read():
- open(str(chat_id) + "/data/scramble.txt", "w").write('True')
- else:
- bot.sendMessage(chat_id, "Game in progress!!")
- if "/type" in message:
- if "True" in open(str(chat_id) + "/data/games.txt", "r").read():
- if "False" in open(str(chat_id) + "/data/type.txt", "r").read():
- open(str(chat_id) + "/data/type.txt", "w").write('True')
- else:
- bot.sendMessage(chat_id, "Game in progress!!")
- def scramble():
- open(str(chat_id) + "/data/scramble.txt", "w").write('inprogress')
- #current_chat_id = str(open(str(chat_id) + "/data/currentchat.txt", "w").write(str(chat_id)))
- rw = RandomWords()
- global word
- word = rw.random_word()
- open(str(chat_id) + "/data/word.txt", "w").write(str(word))
- words = ''.join(random.sample(word, len(word)))
- bot.sendMessage(chat_id, "The word to unscramble is:\n*" + str(words) + "*", parse_mode="markdown")
- print(word)
- endTime = datetime.datetime.now() + datetime.timedelta(seconds=int(open(str(chat_id) + "/data/gamelimit.txt").read()))
- while True:
- if "inprogress" in open(str(chat_id) + "/data/scramble.txt", "r").read():
- if datetime.datetime.now() >= endTime:
- bot.sendMessage(chat_id, "Times up word is *" + str(open(str(chat_id) + "/data/word.txt").read()) + "*", parse_mode="markdown")
- open(str(chat_id) + "/data/scramble.txt", "w").write('False')
- break
- else:
- break
- def type():
- open(str(chat_id) + "/data/type.txt", "w").write('inprogress')
- #current_chat_id = str(open(str(chat_id) + "/data/currentchat.txt", "w").write(str(chat_id)))
- rw = RandomWords()
- global word
- word = rw.random_word()
- open(str(chat_id) + "/data/typeword.txt", "w").write(str(word))
- global start
- start = time.time()
- bot.sendMessage(chat_id, "The word to type is:\n*" + str(word) + "*", parse_mode="markdown")
- print(word)
- endTime = datetime.datetime.now() + datetime.timedelta(seconds=int(open(str(chat_id) + "/data/gamelimit.txt").read()))
- while True:
- if "inprogress" in open(str(chat_id) + "/data/type.txt", "r").read():
- if datetime.datetime.now() >= endTime:
- bot.sendMessage(chat_id, "You took too long to type *" + str(open(str(chat_id) + "/data/typeword.txt").read()) + "*!", parse_mode="markdown")
- open(str(chat_id) + "/data/type.txt", "w").write('False')
- break
- else:
- break
- if messageType != 'private':
- if "True" in open(str(chat_id) + "/data/scramble.txt", "r").read():
- t = threading.Thread(target=scramble)
- t.start()
- if "True" in open(str(chat_id) + "/data/type.txt", "r").read():
- t = threading.Thread(target=type)
- print(threading.activeCount())
- t.start()
- if "inprogress" in open(str(chat_id) + "/data/scramble.txt", "r").read():
- if open(str(chat_id) + "/data/word.txt").read() in message:
- write = int(
- str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", "")) + int(len(str(open(str(chat_id) + "/data/word.txt").read())) * 1)
- write2 = int(
- str(open("rooms/" + str(messageFromID) + "wins.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", "")) + int(1)
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + " wins!")
- open("rooms/" + str(messageFromID) + "wins.txt", "w").write(str(write2))
- open(str(chat_id) + "/data/scramble.txt", "w").write('False')
- open("rooms/" + str(messageFromID) + "money.txt", "w").write(str(write))
- if 'inprogress' in open(str(chat_id) + '/data/type.txt', 'r').read():
- print('THIS IS IT: ' + open(str(chat_id) + "/data/typeword.txt").read() + ' == ' + message)
- if '/type' in message:
- pass
- elif open(str(chat_id) + "/data/typeword.txt").read() in message:
- end = time.time()
- write = int(
- str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", "")) + int(len(word) * 1)
- write2 = int(
- str(open("rooms/" + str(messageFromID) + "wins.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", "")) + int(1)
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + " wins! Took " + str(str(start-end)).replace('-', '')[:4] + ' seconds.')
- open("rooms/" + str(messageFromID) + "wins.txt", "w").write(str(write2))
- open(str(chat_id) + "/data/type.txt", "w").write('False')
- open(str(chat_id) + "/data/typeword.txt", "w").write('zaprt')
- open("rooms/" + str(messageFromID) + "money.txt", "w").write(str(write))
- with open(str(chat_id) + '/data/blacklisted.txt', 'r') as f:
- for line in f:
- blackLISTED = str('\n'.join([x for x in line.split("\n") if x.strip() != ''])).split('\n')
- if any (s in message.lower() for s in blackLISTED):
- if str(msg['from']['id']) in open(str(chat_id) + "/data/admin.txt", "r").read():
- ()
- elif str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- ()
- else:
- if chat_id == -1001120893205:
- ()
- else:
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + ' has been kicked for saying a blacklisted word.')
- bot.kickChatMember(chat_id, str(msg['from']['id']))
- #if messageType != 'private':
- #if "/state" in message:
- # if "True" in open(str(chat_id) + "/data/games.txt", "r").read():
- # if "False" in open(str(chat_id) + "/data/state.txt", "r").read():
- # open(str(chat_id) + "/data/state.txt", "w").write('True')
- # else:
- # bot.sendMessage(chat_id, "Game in progress!!")
- def state():
- open(str(chat_id) + "/data/state.txt", "w").write('inprogress')
- global statename
- statename = ['alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming']
- randomstate = random.choice(statename)
- open(str(chat_id) + "/data/statename.txt", "w").write(str(randomstate).replace('-', ' '))
- bot.sendPhoto(chat_id, open("states/" + str(randomstate) + ".jpg", "rb"))
- print(open(str(chat_id) + "/data/statename.txt", "r").read())
- endTime = datetime.datetime.now() + datetime.timedelta(seconds=int(open(str(chat_id) + "/data/gamelimit.txt").read()))
- while True:
- if "inprogress" in open(str(chat_id) + "/data/state.txt", "r").read():
- if datetime.datetime.now() >= endTime:
- bot.sendMessage(chat_id, "Times up, the state is *" + str(randomstate) + "*", parse_mode="markdown")
- open(str(chat_id) + "/data/state.txt", "w").write('False')
- break
- else:
- break
- if messageType != 'private':
- if "True" in open(str(chat_id) + "/data/state.txt", "r").read():
- t = threading.Thread(target=state)
- t.start()
- if "inprogress" in open(str(chat_id) + "/data/state.txt", "r").read():
- if open(str(chat_id) + "/data/statename.txt", "r").read() in message:
- write = int(
- str(open("rooms/" + str(messageFromID) + "money.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", "")) + 10
- write2 = int(
- str(open("rooms/" + str(messageFromID) + "wins.txt", "r").readlines()).replace("[",
- "").replace(
- "'", "").replace("]", "")) + int(1)
- bot.sendMessage(chat_id, str(msg['from']['first_name']) + " wins!")
- open("rooms/" + str(messageFromID) + "wins.txt", "w").write(str(write2))
- open(str(chat_id) + "/data/state.txt", "w").write('False')
- open("rooms/" + str(messageFromID) + "money.txt", "w").write(str(write))
- if message in commandsList:
- if message in message:
- cont = True
- if cont:
- if message == "hey bot":
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- bot.sendMessage(chat_id, "Hi, " + msg['from']['first_name'][:15] + "!")
- else:
- bot.sendMessage(chat_id, "Hi, " + open("data/n" + str(messageFromID) + ".txt").read() + "!")
- def picturemessage():
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- try:
- color = open(str(chat_id) + "/data/imagecolor.txt").read()
- color1 = open(str(chat_id) + "/data/textcolor.txt").read()
- profiles = bot.getUserProfilePhotos(msg['new_chat_member']['id'])
- file_id = profiles['photos'][0][-1]['file_id']
- filename = str(msg['new_chat_member']['id']) + ".jpg"
- bot.download_file(file_id, filename)
- im = Image.open(filename)
- img = PIL.Image.new("RGB", (640, 800), (color))
- draw = PIL.ImageDraw.Draw(img)
- font = ImageFont.truetype("comic.ttf", int("65"))
- except:
- filename = "NoPFP.jpg"
- im = Image.open(filename)
- img = Image.new("RGB", (640, 800), (color))
- draw = PIL.ImageDraw.Draw(img)
- font = ImageFont.truetype("comic.ttf", int("65"))
- if os.path.isfile("data/n" + str(msg["new_chat_member"]['id']) + ".txt") == False:
- if len(msg['from']['first_name']) > 15:
- line2 = msg["new_chat_member"]['first_name'][:15] + "...!"
- else:
- line2 = msg['new_chat_member']['first_name'] + "!"
- else:
- if len(open("data/n" + str(msg["new_chat_member"]['id']) + ".txt").read()) > 15:
- line2 = open("data/n" + str(msg["new_chat_member"]['id']) + ".txt").read()[:15] + "...!"
- else:
- line2 = open("data/n" + str(msg["new_chat_member"]['id']) + ".txt").read() + "!"
- if os.path.isfile(str(chat_id) + "/data/greettext.txt") == False:
- line1 = "Welcome"
- else:
- line1 = str(open(str(chat_id) + "/data/greettext.txt").read())
- w, h = font.getsize(line1)
- w2, h2 = font.getsize(line2)
- draw.text(((650 - w) / 2, (1360 - h) / 2), line1, font=font, fill=str(color1))
- draw.text(((650 - w2) / 2, ((1300 - h2) / 2) + 100), line2, font=font, fill=str(color1))
- img.paste(im, (0, 0))
- img.save("1" + filename)
- bot.sendPhoto(chat_id, open("1" + filename, "rb"))
- os.remove("1" + filename)
- if filename != "NoPFP.jpg":
- os.remove(filename)
- if 'new_chat_member' in msg:
- if 'username' in msg:
- newuser = str("@" + msg['new_chat_member']['username'])
- else:
- newuser = msg['from']['first_name']
- if 'new_chat_member' in msg:
- newuser = msg['new_chat_member']['first_name']
- print(msg['new_chat_member']['first_name'], "has joined", msg['chat']['title'])
- if msg['new_chat_member']['id'] == botID:
- bot.sendMessage(chat_id, "Hi, I am currently in beta. So if there are any bugs, PM @spoon xoxo")
- else:
- if 'True' in open(str(chat_id) + "/data/lock.txt").read():
- bot.kickChatMember(chat_id, msg['new_chat_member']['id'])
- bot.sendMessage(chat_id, "This group is currently locked. /lock to unlock.")
- else:
- if 'True' in open(str(chat_id) + "/data/antibot.txt").read():
- try:
- if str(msg['new_chat_member']['username']).lower().endswith('bot'):
- bot.kickChatMember(chat_id, msg['new_chat_member']['id'])
- bot.sendMessage(chat_id, "Anti-bot is activated, sorry.")
- except:
- ()
- else:
- if 'True' in open(str(chat_id) + "/wel.txt").read():
- if "Text" in open(str(chat_id) + "/data/greet.txt").read():
- if os.path.isfile(str(chat_id) + "/welcome.txt") == False:
- bot.sendMessage(chat_id,
- "Welcome to the group! The welcome message has not been set. Type '/wel' and then your message. For more help, type /wel")
- else:
- if os.path.isfile("data/n" + str(msg['new_chat_member']['id']) + ".txt") == False:
- f = open(str(chat_id) + "/welcome.txt").read().replace("$n",
- msg['new_chat_member'][
- 'first_name']).replace(
- "$u",
- newuser).replace("$t", msg['chat']['title'])
- bot.sendMessage(chat_id, str(f))
- else:
- f = open(str(chat_id) + "/welcome.txt").read().replace("$n",
- open("data/n" + str(
- msg['new_chat_member']['id']) + ".txt").read()).replace(
- "$u",
- newuser).replace("$t", msg['chat']['title'])
- bot.sendMessage(chat_id, str(f))
- else:
- t = threading.Thread(target=picturemessage)
- t.start()
- else:
- if 'True' in open(str(chat_id) + "/wel.txt").read():
- if "Text" in open(str(chat_id) + "/data/greet.txt").read():
- if os.path.isfile(str(chat_id) + "/welcome.txt") == False:
- bot.sendMessage(chat_id,
- "Welcome to the group! The welcome message has not been set. Type '/wel' and then your message. For more help, type /wel")
- else:
- if os.path.isfile("data/n" + str(msg['new_chat_member']['id']) + ".txt") == False:
- f = open(str(chat_id) + "/welcome.txt").read().replace("$n",
- msg['new_chat_member'][
- 'first_name']).replace(
- "$u",
- newuser).replace("$t", msg['chat']['title'])
- bot.sendMessage(chat_id, str(f))
- else:
- f = open(str(chat_id) + "/welcome.txt").read().replace("$n",
- open("data/n" + str(
- msg['new_chat_member'][
- 'id']) + ".txt").read()).replace(
- "$u",
- newuser).replace("$t", msg['chat']['title'])
- bot.sendMessage(chat_id, str(f))
- else:
- t = threading.Thread(target=picturemessage)
- t.start()
- def check():
- if str(msg['from']['id']) in open(str(chat_id) + "/data/adminlist.data", "r").read():
- f = threading.Thread(target=admincom)
- f.start()
- print(threading.active_count())
- if messageType != 'private':
- t = threading.Thread(target=check)
- t.start()
- if "/callme " in message:
- if len(message[8:]) > 25:
- bot.sendMessage(chat_id, "The limit is 25 characters!")
- elif "nothing" in message:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- bot.sendMessage(chat_id, "You currently have no nicknames, and I won't call you nothing :(")
- else:
- bot.sendMessage(chat_id, "Okay, I won't call you by any nicknames.")
- os.remove("data/n" + str(messageFromID) + ".txt")
- else:
- if "\u2B50" in message:
- bot.sendMessage(chat_id, "You are trying to put a restricted emoji your name. This star is only for admins, please retry.")
- else:
- bot.sendMessage(chat_id, "Okay " + msg['text'][8:].replace(u"\u2B50", "") + ", I'll remember that.")
- open("data/n" + str(messageFromID) + ".txt", "w").write(str(msg['text'][8:]).replace(u"\u2B50", ""))
- if "/me" in message:
- if messageType != 'private':
- with open(str(chat_id) + "/data/numberone.txt", "r") as one:
- for _ in range(1):
- OwnerMessage = one.readline()
- with open(str(chat_id) + "/data/numbertwo.txt", "r") as two:
- for _ in range(1):
- OwnerCoins = two.readline()
- with open(str(chat_id) + "/data/numberthree.txt", "r") as three:
- for _ in range(1):
- OwnerWins = three.readline()
- if '@' in msg['text']:
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][4:]:
- word = str(msg['text'][4:]).replace('@', "").lower()
- else:
- word = str(msg['text'][4:]).lower()
- # iterate over lines, and print out line numbers which contain
- # the word of interest.
- for i, line in enumerate(lines):
- if word in line.lower(): # or word in line.split() to search for full words
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- meProfileUser = lines[i].split(">:>")[0]
- meProfileName = lines[i].split(">:>")[1].replace('\n', '')
- if str(meProfileUser) in OwnerMessage:
- mostMessages = "\nMost Messages Sent \U0001F947"
- else:
- mostMessages = ""
- if str(meProfileUser) in OwnerWins:
- mostWins = "\nMost Wins \U0001F947"
- else:
- mostWins = ""
- if str(meProfileUser) in OwnerCoins:
- mostCoins = "\nMost Coins \U0001F947"
- else:
- mostCoins = ""
- if meProfileUser in open(chat_id + '/data/adminlist.data', 'r').read():
- star = u"\u2B50"
- else:
- if str(meProfileUser) in open(str(chat_id) + "/data/admin.txt").read():
- star = u"\u2B50"
- else:
- star = ""
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>\n/me snapchat <snapchat>\n/me soundcloud <soundcloud>")
- if " instagram " in message:
- if "delete" in msg['text'][14:].lower():
- os.remove("data/insta" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Instagram removed!")
- else:
- if len(msg['text'][14:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Instagram name.")
- else:
- open("data/insta" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][14:]))
- bot.sendMessage(chat_id, "Instagram set!")
- if " time " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/time" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Time removed!")
- else:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- try:
- place, (lat, lng) = geolocator.geocode(
- msg['text'][9:])
- open("data/time" + str(meProfileUser) + ".txt", 'w').write(msg['text'][9:])
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- bot.sendMessage(chat_id, 'Set time!')
- except:
- bot.sendMessage(chat_id, 'Not a valid location!')
- if " psn " in message:
- if "delete" in msg['text'][8:].lower():
- os.remove("data/psn" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "PlayStation removed!")
- else:
- if len(msg['text'][8:].lower()) > 16:
- bot.sendMessage(chat_id, "Not a valid PlayStation name.")
- else:
- open("data/psn" + str(meProfileUser) + ".txt",
- "w").write(
- str(msg['text'][8:]))
- bot.sendMessage(chat_id, "PlayStation set!")
- if " xbox " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/xbox" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Xbox removed!")
- else:
- if len(msg['text'][9].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Xbox name.")
- else:
- open("data/xbox" + str(meProfileUser) + ".txt",
- "w").write(
- str(msg['text'][9:]))
- bot.sendMessage(chat_id, "Xbox set!")
- if " lock" in message:
- if "True" in open(str("data/locked" + str(meProfileUser) + ".txt"), "r"):
- open("data/locked" + str(meProfileUser) + ".txt", "w").write("False")
- bot.sendMessage(chat_id,
- "Your /me profile has been unlocked, anyone who replies to your message with /me will be able to see it!")
- else:
- open("data/locked" + str(meProfileUser) + ".txt", "w").write("True")
- bot.sendMessage(chat_id,
- "Your /me profile has been locked, anyone who replies to your message with /me will not be able to see it!")
- if " reddit " in message:
- if "delete" in msg['text'][11:].lower():
- os.remove("data/red" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Reddit removed!")
- else:
- if len(msg['text'][11:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Reddit name.")
- else:
- open("data/red" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][11:]))
- bot.sendMessage(chat_id, "Reddit set!")
- if " steam " in message:
- if "delete" in msg['text'][10:].lower():
- os.remove("data/steam" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][10:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Steam name.")
- else:
- open("data/steam" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][10:]))
- bot.sendMessage(chat_id, "Steam set!")
- if " soundcloud " in message:
- if "delete" in msg['text'][15:].lower():
- os.remove("data/soundcloud" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][15:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
- else:
- open("data/soundcloud" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][15:]))
- bot.sendMessage(chat_id, "Soundcloud set!")
- if " snapchat " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/snapchat" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Snapchat removed!")
- else:
- if len(msg['text'][13:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Snapchat name.")
- else:
- open("data/snapchat" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Snapchat set!")
- if os.path.isfile(("data/soundcloud" + str(meProfileUser) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(meProfileUser) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(("data/snapchat" + str(meProfileUser) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(meProfileUser) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if " location " in message:
- if "delete" in msg['text'][13].lower():
- os.remove("data/loc" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Location removed!")
- else:
- if len(msg['text'][13:].lower()) > 30:
- bot.sendMessage(chat_id, "Not a valid Location name.")
- else:
- open("data/loc" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Location set!")
- if os.path.isfile(("data/insta" + str(meProfileUser) + ".txt")) == True:
- Instagram = str(
- "Instagram: [" + str(open("data/insta" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(meProfileUser) + ".txt", "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/steam" + str(meProfileUser) + ".txt")) == True:
- Steam = str("Steam: [" + str(open("data/steam" + str(meProfileUser) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(meProfileUser) + ".txt", "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(("data/xbox" + str(meProfileUser) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(meProfileUser) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(meProfileUser) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/red" + str(meProfileUser) + ".txt")) == True:
- Reddit = str("Reddit: [" + str(open("data/red" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(meProfileUser) + ".txt", "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(("data/loc" + str(meProfileUser) + ".txt")) == True:
- Location = str("Location: [" + str(open("data/loc" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(meProfileUser) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(meProfileUser) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(meProfileUser) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(meProfileUser) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(open(str(chat_id) + "/data/" + str(meProfileUser) + ".txt",
- "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if os.path.isfile(("data/time" + str(meProfileUser) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(
- str(open("data/time" + str(meProfileUser) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- usermessages = open(str(chat_id) + "/messages/" + str(meProfileUser) + ".txt", "r").read()
- groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
- percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
- print(percentage)
- if os.path.isfile("data/n" + str(meProfileUser) + ".txt") == True:
- name = open("data/n" + str(meProfileUser) + ".txt").read()
- else:
- name = meProfileName
- print(name)
- if "/me" in msg['text']:
- print('yes')
- bot.sendMessage(chat_id, "*" + name + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(meProfileUser) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(meProfileUser) + "wins.txt",
- "r").read()) + str(mostCoins) + str(mostWins) + str(mostMessages) + "*\n%s%s%s%s%s%s%s%s%s%sYou've sent " % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX) + open(
- str(chat_id) +
- "/messages/" + str(meProfileUser) + ".txt", "r").read() + " (" + str(
- percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
- "r").read() + " messages.",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- if 'reply_to_message' in msg:
- print(OwnerWins)
- print(msg['reply_to_message']['from']['id'])
- if str(msg['reply_to_message']['from']['id']) in OwnerMessage:
- mostMessages = "\nMost Messages Sent \U0001F947"
- else:
- mostMessages = ""
- if str(msg['reply_to_message']['from']['id']) in OwnerWins:
- mostWins = "\nMost Wins \U0001F947"
- else:
- mostWins = ""
- if str(msg['reply_to_message']['from']['id']) in OwnerCoins:
- mostCoins = "\nMost Coins \U0001F947"
- else:
- mostCoins = ""
- if str(msg['reply_to_message']['from']['id']) in open(chat_id + '/data/adminlist.data', 'r').read():
- star = u"\u2B50"
- else:
- if str(msg['reply_to_message']['from']['id']) in open(str(chat_id) + "/data/admin.txt").read():
- star = u"\u2B50"
- else:
- star = ""
- if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == True:
- name = open("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt").read()
- else:
- msg['from']['first_name'][:15]
- if os.path.isfile(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt") == True:
- Warns = str("Amount of warns: *(" + str(
- open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if os.path.isfile("data/n" + str(msg['reply_to_message']['from']['id']) + ".txt") == False:
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>\n/me snapchat <snapchat>\n/me soundcloud <soundcloud>")
- if os.path.isfile(
- ("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Instagram = str("Instagram: [" + str(
- open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(
- ("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Steam = str("Steam: [" + str(
- open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(
- ("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(
- ("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Reddit = str(
- "Reddit: [" + str(
- open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(
- ("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if os.path.isfile(("data/psn" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(("data/xbox" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/time" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(
- str(open("data/time" + str(msg['reply_to_message']['from']['id']) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- if os.path.isfile(
- ("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Location = str("Location: [" + str(
- open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()).replace(" ", "+") + ")\n")
- else:
- Location = ""
- usermessages = open(str(chat_id) + "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()
- groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
- percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
- print(percentage)
- if message == "/me":
- if "False" in open(str("data/locked" + str(msg['reply_to_message']['from']['id']) + ".txt"), "r"):
- bot.sendMessage(chat_id,
- "*" + msg['reply_to_message']['from']['first_name'] + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "wins.txt",
- "r").read()) + str(mostCoins) + str(mostWins) + str(mostMessages) + "*\n%s%s%s%s%s%s%s%s%s%sYou've sent " % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX) + open(
- str(chat_id) +
- "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read() + " (" + str(
- percentage) + "%) and this group has " + open(
- str(chat_id) + "/messagecount.txt",
- "r").read() + " messages.",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- bot.sendMessage(chat_id, "*" + msg['reply_to_message']['from']['first_name'] + " " + star + "*\n\nThis account is locked! \U0001F512",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- if str(msg['reply_to_message']['from']['id']) in OwnerMessage:
- mostMessages = "\nMost Messages Sent \U0001F947"
- else:
- mostMessages = ""
- if str(msg['reply_to_message']['from']['id']) in OwnerWins:
- mostWins = "\nMost Wins \U0001F947"
- else:
- mostWins = ""
- if str(msg['reply_to_message']['from']['id']) in OwnerCoins:
- mostCoins = "\nMost Coins \U0001F947"
- else:
- mostCoins = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(
- msg['reply_to_message']['from']['id']) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(
- open(str(chat_id) + "/data/" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>\n/me snapchat <snapchat>\n/me soundcloud <soundcloud>")
- if os.path.isfile(
- ("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Instagram = str("Instagram: [" + str(
- open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/xbox" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(
- ("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Steam = str("Steam: [" + str(
- open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(
- ("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(
- ("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Reddit = str(
- "Reddit: [" + str(
- open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(
- ("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if os.path.isfile(
- ("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- Location = str("Location: [" + str(
- open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()).replace(" ", "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(("data/time" + str(msg['reply_to_message']['from']['id']) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(
- str(open("data/time" + str(msg['reply_to_message']['from']['id']) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- usermessages = open(str(chat_id) + "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt",
- "r").read()
- groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
- percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
- print(percentage)
- if message == "/me":
- if "False" in open(str("data/locked" + str(msg['reply_to_message']['from']['id']) + ".txt"), "r"):
- bot.sendMessage(chat_id, "*" + name + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(msg['reply_to_message']['from']['id']) + "wins.txt",
- "r").read()) + str(mostCoins) + str(mostWins) + str(mostMessages) + "*\n%s%s%s%s%s%s%s%s%s%sYou've sent " % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX) + open(
- str(chat_id) +
- "/messages/" + str(msg['reply_to_message']['from']['id']) + ".txt", "r").read() + " (" + str(
- percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
- "r").read() + " messages.",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- bot.sendMessage(chat_id, "*" + name + " " + star + "*\n\nThis account is locked! \U0001F512",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- if str(msg['from']['id']) in OwnerMessage:
- mostMessages = "\nMost Messages Sent \U0001F947"
- else:
- mostMessages = ""
- if str(msg['from']['id']) in OwnerWins:
- mostWins = "\nMost Wins \U0001F947"
- else:
- mostWins = ""
- if str(msg['from']['id']) in OwnerCoins:
- mostCoins = "\nMost Coins \U0001F947"
- else:
- mostCoins = ""
- if str(msg['from']['id']) in open(chat_id + '/data/adminlist.data', 'r').read():
- star = u"\u2B50"
- else:
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt").read():
- star = u"\u2B50"
- else:
- star = ""
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>\n/me snapchat <snapchat>\n/me soundcloud <soundcloud>")
- if " instagram " in message:
- if "delete" in msg['text'][14:].lower():
- os.remove("data/insta" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Instagram removed!")
- else:
- if len(msg['text'][14:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Instagram name.")
- else:
- open("data/insta" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][14:]))
- bot.sendMessage(chat_id, "Instagram set!")
- if " time " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/time" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Time removed!")
- else:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- try:
- place, (lat, lng) = geolocator.geocode(
- msg['text'][9:])
- open("data/time" + str(messageFromID) + ".txt", 'w').write(msg['text'][9:])
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- bot.sendMessage(chat_id, 'Set time!')
- except:
- bot.sendMessage(chat_id, 'Not a valid location!')
- if " psn " in message:
- if "delete" in msg['text'][8:].lower():
- os.remove("data/psn" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "PlayStation removed!")
- else:
- if len(msg['text'][8:].lower()) > 16:
- bot.sendMessage(chat_id, "Not a valid PlayStation name.")
- else:
- open("data/psn" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][8:]))
- bot.sendMessage(chat_id, "PlayStation set!")
- if " xbox " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/xbox" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Xbox removed!")
- else:
- if len(msg['text'][9].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Xbox name.")
- else:
- open("data/xbox" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][9:]))
- bot.sendMessage(chat_id, "Xbox set!")
- if " lock" in message:
- if "True" in open(str("data/locked" + str(messageFromID) + ".txt"), "r"):
- open("data/locked" + str(messageFromID) + ".txt", "w").write("False")
- bot.sendMessage(chat_id,
- "Your /me profile has been unlocked, anyone who replies to your message with /me will be able to see it!")
- else:
- open("data/locked" + str(messageFromID) + ".txt", "w").write("True")
- bot.sendMessage(chat_id,
- "Your /me profile has been locked, anyone who replies to your message with /me will not be able to see it!")
- if " reddit " in message:
- if "delete" in msg['text'][11:].lower():
- os.remove("data/red" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Reddit removed!")
- else:
- if len(msg['text'][11:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Reddit name.")
- else:
- open("data/red" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][11:]))
- bot.sendMessage(chat_id, "Reddit set!")
- if " steam " in message:
- if "delete" in msg['text'][10:].lower():
- os.remove("data/steam" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][10:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Steam name.")
- else:
- open("data/steam" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][10:]))
- bot.sendMessage(chat_id, "Steam set!")
- if " soundcloud " in message:
- if "delete" in msg['text'][15:].lower():
- os.remove("data/soundcloud" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][15:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
- else:
- open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][15:]))
- bot.sendMessage(chat_id, "Soundcloud set!")
- if " snapchat " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/snapchat" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Snapchat removed!")
- else:
- if len(msg['text'][13:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Snapchat name.")
- else:
- open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Snapchat set!")
- if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if " location " in message:
- if "delete" in msg['text'][13].lower():
- os.remove("data/loc" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Location removed!")
- else:
- if len(msg['text'][13:].lower()) > 30:
- bot.sendMessage(chat_id, "Not a valid Location name.")
- else:
- open("data/loc" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Location set!")
- if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
- Instagram = str(
- "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
- Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(("data/xbox" + str(messageFromID) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(messageFromID) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
- Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
- Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(messageFromID) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(messageFromID) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(open(str(chat_id) + "/data/" + str(messageFromID) + ".txt",
- "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if os.path.isfile(("data/time" + str(messageFromID) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(
- str(open("data/time" + str(messageFromID) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- usermessages = open(str(chat_id) + "/messages/" + str(messageFromID) + ".txt", "r").read()
- groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
- percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
- print(percentage)
- if message == "/me":
- bot.sendMessage(chat_id, "*" + msg['from']['first_name'] + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(messageFromID) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(messageFromID) + "wins.txt",
- "r").read()) + str(mostCoins) + str(mostWins) + str(mostMessages) + "*\n%s%s%s%s%s%s%s%s%s%sYou've sent " % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX) + open(
- str(chat_id) +
- "/messages/" + str(messageFromID) + ".txt", "r").read() + " (" + str(
- percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
- "r").read() + " messages.",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- if str(msg['from']['id']) in OwnerMessage:
- mostMessages = "\nMost Messages Sent \U0001F947"
- else:
- mostMessages = ""
- if str(msg['from']['id']) in OwnerWins:
- mostWins = "\nMost Wins \U0001F947"
- else:
- mostWins = ""
- if str(msg['from']['id']) in OwnerCoins:
- mostCoins = "\nMost Coins \U0001F947"
- else:
- mostCoins = ""
- if str(messageFromID) in open(chat_id + '/data/adminlist.data', 'r').read():
- star = u"\u2B50"
- else:
- if str(messageFromID) in open(str(chat_id) + "/data/admin.txt").read():
- star = u"\u2B50"
- else:
- star = ""
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me snapchat <snapchat username>\n/me soundcloud <soundcloud username>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>")
- if " instagram " in message:
- if "delete" in msg['text'][14:].lower():
- os.remove("data/insta" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Instagram removed!")
- else:
- if len(msg['text'][14:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Instagram name.")
- else:
- open("data/insta" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][14:]))
- bot.sendMessage(chat_id, "Instagram set!")
- if " time " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/time" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Time removed!")
- else:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- try:
- place, (lat, lng) = geolocator.geocode(
- msg['text'][9:])
- open("data/time" + str(messageFromID) + ".txt", 'w').write(msg['text'][9:])
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- bot.sendMessage(chat_id, 'Set time!')
- except:
- bot.sendMessage(chat_id, 'Not a valid location!')
- if " psn " in message:
- if "delete" in msg['text'][8:].lower():
- os.remove("data/psn" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "PlayStation removed!")
- else:
- if len(msg['text'][8:].lower()) > 16:
- bot.sendMessage(chat_id, "Not a valid PlayStation name.")
- else:
- open("data/psn" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][8:]))
- bot.sendMessage(chat_id, "PlayStation set!")
- if " xbox " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/xbox" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Xbox removed!")
- else:
- if len(msg['text'][9].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Xbox name.")
- else:
- open("data/xbox" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][9:]))
- bot.sendMessage(chat_id, "Xbox set!")
- if " lock" in message:
- if "True" in open(str("data/locked" + str(messageFromID) + ".txt"), "r"):
- open("data/locked" + str(messageFromID) + ".txt", "w").write("False")
- bot.sendMessage(chat_id,
- "Your /me profile has been unlocked, anyone who replies to your message with /me will be able to see it!")
- else:
- open("data/locked" + str(messageFromID) + ".txt", "w").write("True")
- bot.sendMessage(chat_id,
- "Your /me profile has been locked, anyone who replies to your message with /me will not be able to see it!")
- if " snapchat " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/snapchat" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Snapchat removed!")
- else:
- if len(msg['text'][13:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Snapchat name.")
- else:
- open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Snapchat set!")
- if " reddit " in message:
- if "delete" in msg['text'][11:].lower():
- os.remove("data/red" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Reddit removed!")
- else:
- if len(msg['text'][11:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Reddit name.")
- else:
- open("data/red" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][11:]))
- bot.sendMessage(chat_id, "Reddit set!")
- if " soundcloud " in message:
- if "delete" in msg['text'][15:].lower():
- os.remove("data/soundcloud" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Soundcloud removed!")
- else:
- if len(msg['text'][15:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
- else:
- open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][15:]))
- bot.sendMessage(chat_id, "Soundcloud set!")
- if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if " steam " in message:
- if "delete" in msg['text'][10:].lower():
- os.remove("data/steam" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][10:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Steam name.")
- else:
- open("data/steam" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][10:]))
- bot.sendMessage(chat_id, "Steam set!")
- if " location " in message:
- if "delete" in msg['text'].lower():
- os.remove("data/loc" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Location removed!")
- else:
- if len(msg['text'].lower()) > 30:
- bot.sendMessage(chat_id, "Not a valid Location name.")
- else:
- open("data/loc" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Location set!")
- if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
- Instagram = str(
- "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
- Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
- Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(("data/xbox" + str(messageFromID) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(messageFromID) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
- Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(messageFromID) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(messageFromID) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(
- open(str(chat_id) + "/data/" + str(messageFromID) + ".txt", "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if os.path.isfile(("data/time" + str(messageFromID) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(
- str(open("data/time" + str(messageFromID) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- usermessages = open(str(chat_id) + "/messages/" + str(messageFromID) + ".txt", "r").read()
- groupmessages = open(str(chat_id) + "/messagecount.txt", "r").read()
- percentage = round((int(usermessages) / int(groupmessages)) * 100, 2)
- print(percentage)
- if message == "/me":
- bot.sendMessage(chat_id, "*" + open(
- "data/n" + str(messageFromID) + ".txt").read() + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(messageFromID) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(messageFromID) + "wins.txt",
- "r").read()) + str(mostCoins) + str(mostWins) + str(mostMessages) + "*\n%s%s%s%s%s%s%s%s%s%sYou've sent " % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX) + open(str(chat_id) +
- "/messages/" + str(
- messageFromID) + ".txt", "r").read() + " (" + str(
- percentage) + "%) and this group has " + open(str(chat_id) + "/messagecount.txt",
- "r").read() + " messages.",
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- if '@' in msg['text']:
- with open("data/listofusers.data", 'r') as f:
- lines = f.read().split("\n")
- # print("Number of lines is {}".format(len(lines)))
- if '@' in msg['text'][4:]:
- word = str(msg['text'][4:]).replace('@', "").lower()
- else:
- word = str(msg['text'][4:]).lower()
- # iterate over lines, and print out line numbers which contain
- # the word of interest.
- for i, line in enumerate(lines):
- if word in line.lower(): # or word in line.split() to search for full words
- # print("Word \"{}\" found in line {}".format(word, i + 1))
- foundLine = i
- f = open("data/listofusers.data")
- lines = f.readlines()
- meProfileUser = lines[i].split(">:>")[0]
- meProfileName = lines[i].split(">:>")[1].replace('\n', '')
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>\n/me snapchat <snapchat>\n/me soundcloud <soundcloud>")
- if " instagram " in message:
- if "delete" in msg['text'][14:].lower():
- os.remove("data/insta" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Instagram removed!")
- else:
- if len(msg['text'][14:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Instagram name.")
- else:
- open("data/insta" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][14:]))
- bot.sendMessage(chat_id, "Instagram set!")
- if " time " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/time" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Time removed!")
- else:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- try:
- place, (lat, lng) = geolocator.geocode(
- msg['text'][9:])
- open("data/time" + str(meProfileUser) + ".txt", 'w').write(msg['text'][9:])
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- bot.sendMessage(chat_id, 'Set time!')
- except:
- bot.sendMessage(chat_id, 'Not a valid location!')
- if " psn " in message:
- if "delete" in msg['text'][8:].lower():
- os.remove("data/psn" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "PlayStation removed!")
- else:
- if len(msg['text'][8:].lower()) > 16:
- bot.sendMessage(chat_id, "Not a valid PlayStation name.")
- else:
- open("data/psn" + str(meProfileUser) + ".txt",
- "w").write(
- str(msg['text'][8:]))
- bot.sendMessage(chat_id, "PlayStation set!")
- if " xbox " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/xbox" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Xbox removed!")
- else:
- if len(msg['text'][9].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Xbox name.")
- else:
- open("data/xbox" + str(meProfileUser) + ".txt",
- "w").write(
- str(msg['text'][9:]))
- bot.sendMessage(chat_id, "Xbox set!")
- if " lock" in message:
- if "True" in open(str("data/locked" + str(meProfileUser) + ".txt"), "r"):
- open("data/locked" + str(meProfileUser) + ".txt", "w").write("False")
- bot.sendMessage(chat_id,
- "Your /me profile has been unlocked, anyone who replies to your message with /me will be able to see it!")
- else:
- open("data/locked" + str(meProfileUser) + ".txt", "w").write("True")
- bot.sendMessage(chat_id,
- "Your /me profile has been locked, anyone who replies to your message with /me will not be able to see it!")
- if " reddit " in message:
- if "delete" in msg['text'][11:].lower():
- os.remove("data/red" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Reddit removed!")
- else:
- if len(msg['text'][11:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Reddit name.")
- else:
- open("data/red" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][11:]))
- bot.sendMessage(chat_id, "Reddit set!")
- if " steam " in message:
- if "delete" in msg['text'][10:].lower():
- os.remove("data/steam" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][10:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Steam name.")
- else:
- open("data/steam" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][10:]))
- bot.sendMessage(chat_id, "Steam set!")
- if " soundcloud " in message:
- if "delete" in msg['text'][15:].lower():
- os.remove("data/soundcloud" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][15:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
- else:
- open("data/soundcloud" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][15:]))
- bot.sendMessage(chat_id, "Soundcloud set!")
- if " snapchat " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/snapchat" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Snapchat removed!")
- else:
- if len(msg['text'][13:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Snapchat name.")
- else:
- open("data/snapchat" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Snapchat set!")
- if os.path.isfile(("data/soundcloud" + str(meProfileUser) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(meProfileUser) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(("data/snapchat" + str(meProfileUser) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(meProfileUser) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if " location " in message:
- if "delete" in msg['text'][13].lower():
- os.remove("data/loc" + str(meProfileUser) + ".txt")
- bot.sendMessage(chat_id, "Location removed!")
- else:
- if len(msg['text'][13:].lower()) > 30:
- bot.sendMessage(chat_id, "Not a valid Location name.")
- else:
- open("data/loc" + str(meProfileUser) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Location set!")
- if os.path.isfile(("data/insta" + str(meProfileUser) + ".txt")) == True:
- Instagram = str(
- "Instagram: [" + str(open("data/insta" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(meProfileUser) + ".txt", "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/steam" + str(meProfileUser) + ".txt")) == True:
- Steam = str("Steam: [" + str(open("data/steam" + str(meProfileUser) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(meProfileUser) + ".txt", "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(("data/xbox" + str(meProfileUser) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(meProfileUser) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(meProfileUser) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/red" + str(meProfileUser) + ".txt")) == True:
- Reddit = str("Reddit: [" + str(open("data/red" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(meProfileUser) + ".txt", "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(("data/loc" + str(meProfileUser) + ".txt")) == True:
- Location = str("Location: [" + str(open("data/loc" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(meProfileUser) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(meProfileUser) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(meProfileUser) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(meProfileUser) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(meProfileUser) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(open(str(chat_id) + "/data/" + str(meProfileUser) + ".txt",
- "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if os.path.isfile(("data/time" + str(meProfileUser) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(
- str(open("data/time" + str(meProfileUser) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- if os.path.isfile("data/n" + str(meProfileUser) + ".txt") == True:
- name = open("data/n" + str(meProfileUser) + ".txt").read()
- else:
- name = meProfileName
- print(name)
- if "/me" in msg['text']:
- print('yes')
- bot.sendMessage(chat_id, "*" + name + " " + "*\n\nCoins: *" + str(
- open("rooms/" + str(meProfileUser) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(meProfileUser) + "wins.txt",
- "r").read()) + "*\n%s%s%s%s%s%s%s%s%s%s" % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX),
- parse_mode="markdown", disable_web_page_preview=True)
- else:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == False:
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>\n/me snapchat <snapchat>\n/me soundcloud <soundcloud>")
- if " instagram " in message:
- if "delete" in msg['text'][14:].lower():
- os.remove("data/insta" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Instagram removed!")
- else:
- if len(msg['text'][14:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Instagram name.")
- else:
- open("data/insta" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][14:]))
- bot.sendMessage(chat_id, "Instagram set!")
- if " time " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/time" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Time removed!")
- else:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- try:
- place, (lat, lng) = geolocator.geocode(
- msg['text'][9:])
- open("data/time" + str(messageFromID) + ".txt", 'w').write(msg['text'][9:])
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- bot.sendMessage(chat_id, 'Set time!')
- except:
- bot.sendMessage(chat_id, 'Not a valid location!')
- if " psn " in message:
- if "delete" in msg['text'][8:].lower():
- os.remove("data/psn" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "PlayStation removed!")
- else:
- if len(msg['text'][8:].lower()) > 16:
- bot.sendMessage(chat_id, "Not a valid PlayStation name.")
- else:
- open("data/psn" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][8:]))
- bot.sendMessage(chat_id, "PlayStation set!")
- if " xbox " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/xbox" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Xbox removed!")
- else:
- if len(msg['text'][9].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Xbox name.")
- else:
- open("data/xbox" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][9:]))
- bot.sendMessage(chat_id, "Xbox set!")
- if " reddit " in message:
- if "delete" in msg['text'][11:].lower():
- os.remove("data/red" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Reddit removed!")
- else:
- if len(msg['text'][11:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Reddit name.")
- else:
- open("data/red" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][11:]))
- bot.sendMessage(chat_id, "Reddit set!")
- if " lock" in message:
- if "True" in open(str("data/locked" + str(messageFromID) + ".txt"), "r"):
- open("data/locked" + str(messageFromID) + ".txt", "w").write("False")
- bot.sendMessage(chat_id,
- "Your /me profile has been unlocked, anyone who replies to your message with /me will be able to see it!")
- else:
- open(str("data/locked" + str(messageFromID) + ".txt")).write("True")
- open("data/locked" + str(messageFromID) + ".txt", "w").write("True")
- bot.sendMessage(chat_id,
- "Your /me profile has been locked, anyone who replies to your message with /me will not be able to see it!")
- if " steam " in message:
- if "delete" in msg['text'][10:].lower():
- os.remove("data/steam" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][10:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Steam name.")
- else:
- open("data/steam" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][10:]))
- bot.sendMessage(chat_id, "Steam set!")
- if " soundcloud " in message:
- if "delete" in msg['text'][15:].lower():
- os.remove("data/soundcloud" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Soundcloud removed!")
- else:
- if len(msg['text'][15:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
- else:
- open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][15:]))
- bot.sendMessage(chat_id, "Soundcloud set!")
- if " snapchat " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/snapchat" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Snapchat removed!")
- else:
- if len(msg['text'][13:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Snapchat name.")
- else:
- open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Snapchat set!")
- if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if " location " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/loc" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Location removed!")
- else:
- if len(msg['text'][13:].lower()) > 30:
- bot.sendMessage(chat_id, "Not a valid Location name.")
- else:
- open("data/loc" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Location set!")
- if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
- Instagram = str(
- "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
- Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
- Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(("data/xbox" + str(messageFromID) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(messageFromID) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
- Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(messageFromID) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(messageFromID) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(open(str(chat_id) + "/data/" + str(messageFromID) + ".txt",
- "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if os.path.isfile(("data/time" + str(messageFromID) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(str(open("data/time" + str(messageFromID) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- if message == "/me":
- bot.sendMessage(chat_id, "*" + msg['from']['first_name'] + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(messageFromID) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(messageFromID) + "wins.txt",
- "r").read()) + "*\n%s%s%s%s%s%s%s%s%s%s" % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX), parse_mode="markdown", disable_web_page_preview=True)
- else:
- star = ""
- if " help" in message:
- bot.sendMessage(chat_id,
- "You can add links to your /me message by sending this:\n/me instagram <instagram username>\n/me time <location for time>\n/me snapchat <snapchat username>\n/me soundcloud <soundcloud username>\n/me reddit <reddit username>\n/me steam <steam username>\n/me location <location>")
- if " instagram " in message:
- if "delete" in msg['text'][14:].lower():
- os.remove("data/insta" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Instagram removed!")
- else:
- if len(msg['text'][14:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Instagram name.")
- else:
- open("data/insta" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][14:]))
- bot.sendMessage(chat_id, "Instagram set!")
- if " time " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/time" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Time removed!")
- else:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- try:
- place, (lat, lng) = geolocator.geocode(
- msg['text'][9:])
- open("data/time" + str(messageFromID) + ".txt", 'w').write(msg['text'][9:])
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- bot.sendMessage(chat_id, 'Set time!')
- except:
- bot.sendMessage(chat_id, 'Not a valid location!')
- if " psn " in message:
- if "delete" in msg['text'][8:].lower():
- os.remove("data/psn" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "PlayStation removed!")
- else:
- if len(msg['text'][8:].lower()) > 16:
- bot.sendMessage(chat_id, "Not a valid PlayStation name.")
- else:
- open("data/psn" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][8:]))
- bot.sendMessage(chat_id, "PlayStation set!")
- if " xbox " in message:
- if "delete" in msg['text'][9:].lower():
- os.remove("data/xbox" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Xbox removed!")
- else:
- if len(msg['text'][9].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Xbox name.")
- else:
- open("data/xbox" + str(messageFromID) + ".txt",
- "w").write(
- str(msg['text'][9:]))
- bot.sendMessage(chat_id, "Xbox set!")
- if " lock" in message:
- if "True" in open(str("data/locked" + str(messageFromID) + ".txt"), "r"):
- open("data/locked" + str(messageFromID) + ".txt", "w").write("False")
- bot.sendMessage(chat_id,
- "Your /me profile has been unlocked, anyone who replies to your message with /me will be able to see it!")
- else:
- open(str("data/locked" + str(messageFromID) + ".txt")).write("True")
- open("data/locked" + str(messageFromID) + ".txt", "w").write("True")
- bot.sendMessage(chat_id,
- "Your /me profile has been locked, anyone who replies to your message with /me will not be able to see it!")
- if " snapchat " in message:
- if "delete" in msg['text'][13:].lower():
- os.remove("data/snapchat" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Snapchat removed!")
- else:
- if len(msg['text'][13:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Snapchat name.")
- else:
- open("data/snapchat" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Snapchat set!")
- if " reddit " in message:
- if "delete" in msg['text'][11:].lower():
- os.remove("data/red" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Reddit removed!")
- else:
- if len(msg['text'][11:].lower()) > 15:
- bot.sendMessage(chat_id, "Not a valid Reddit name.")
- else:
- open("data/red" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][11:]))
- bot.sendMessage(chat_id, "Reddit set!")
- if " soundcloud " in message:
- if "delete" in msg['text'][15:].lower():
- os.remove("data/soundcloud" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][15:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Soundcloud name.")
- else:
- open("data/soundcloud" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][15:]))
- bot.sendMessage(chat_id, "Soundcloud set!")
- if os.path.isfile(("data/soundcloud" + str(messageFromID) + ".txt")) == True:
- Soundcloud = str("Soundcloud: [" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + "](https://soundcloud.com/" + str(
- open("data/soundcloud" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Soundcloud = ""
- if os.path.isfile(("data/snapchat" + str(messageFromID) + ".txt")) == True:
- Snapchat = str("Snapchat: [" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.snapchat.com/add/" + str(
- open("data/snapchat" + str(messageFromID) + ".txt",
- "r").read()) + ")\n")
- else:
- Snapchat = ""
- if " steam " in message:
- if "delete" in msg['text'][10:].lower():
- os.remove("data/steam" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Steam removed!")
- else:
- if len(msg['text'][10:].lower()) > 20:
- bot.sendMessage(chat_id, "Not a valid Steam name.")
- else:
- open("data/steam" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][10:]))
- bot.sendMessage(chat_id, "Steam set!")
- if " location " in message:
- if "delete" in msg['text'].lower():
- os.remove("data/loc" + str(messageFromID) + ".txt")
- bot.sendMessage(chat_id, "Location removed!")
- else:
- if len(msg['text'].lower()) > 30:
- bot.sendMessage(chat_id, "Not a valid Location name.")
- else:
- open("data/loc" + str(messageFromID) + ".txt", "w").write(
- str(msg['text'][13:]))
- bot.sendMessage(chat_id, "Location set!")
- if os.path.isfile(("data/insta" + str(messageFromID) + ".txt")) == True:
- Instagram = str(
- "Instagram: [" + str(open("data/insta" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.instagram.com/" + str(
- open("data/insta" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Instagram = ""
- if os.path.isfile(("data/steam" + str(messageFromID) + ".txt")) == True:
- Steam = str("Steam: [" + str(open("data/steam" + str(messageFromID) + ".txt",
- "r").read()) + "](http://steamcommunity.com/id/" + str(
- open("data/steam" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Steam = ""
- if os.path.isfile(("data/red" + str(messageFromID) + ".txt")) == True:
- Reddit = str("Reddit: [" + str(open("data/red" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.reddit.com/user/" + str(
- open("data/red" + str(messageFromID) + ".txt", "r").read()) + ")\n")
- else:
- Reddit = ""
- if os.path.isfile(("data/loc" + str(messageFromID) + ".txt")) == True:
- Location = str("Location: [" + str(open("data/loc" + str(messageFromID) + ".txt",
- "r").read()) + "](https://www.google.com/#q=" + str(
- open("data/loc" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- Location = ""
- if os.path.isfile(("data/psn" + str(messageFromID) + ".txt")) == True:
- PSN = str("PSN: [" + str(open("data/psn" + str(messageFromID) + ".txt",
- "r").read()) + "](https://my.playstation.com/" + str(
- open("data/psn" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- PSN = ""
- if os.path.isfile(("data/xbox" + str(messageFromID) + ".txt")) == True:
- XBOX = str("Xbox: [" + str(open("data/xbox" + str(messageFromID) + ".txt",
- "r").read()) + "](http://live.xbox.com/en-US/Profile?gamertag=" + str(
- open("data/xbox" + str(messageFromID) + ".txt", "r").read()).replace(" ",
- "+") + ")\n")
- else:
- XBOX = ""
- if os.path.isfile(("data/time" + str(messageFromID) + ".txt")) == True:
- tf = timezonefinder.TimezoneFinder()
- geo_keys = ['AIzaSyC9CNdTPQGkmm2Wq6e3e-DnC96lNTsdp8s']
- geolocator = geocoders.GoogleV3(api_key=random.choice(geo_keys))
- place, (lat, lng) = geolocator.geocode(str(open("data/time" + str(messageFromID) + ".txt", 'r').read()))
- timezone_str = tf.certain_timezone_at(lat=lat, lng=lng)
- location = timezone(str(timezone_str))
- location_time = datetime.datetime.now(location)
- userTime = str("Current Time: *" + location_time.strftime('%I:%M %p') + "*\n")
- else:
- userTime = ""
- if os.path.isfile(str(chat_id) + "/data/" + str(messageFromID) + ".txt") == True:
- Warns = str(
- "Amount of warns: *(" + str(
- open(str(chat_id) + "/data/" + str(messageFromID) + ".txt", "r").read()) + "/3)*\n")
- else:
- Warns = ""
- if message == "/me":
- bot.sendMessage(chat_id, "*" + open(
- "data/n" + str(messageFromID) + ".txt").read() + " " + star + "*\n\nCoins: *" + str(
- open("rooms/" + str(messageFromID) + "money.txt",
- "r").read()) + "\n*Wins: *" + str(
- open("rooms/" + str(messageFromID) + "wins.txt",
- "r").read()) + "*\n%s%s%s%s%s%s%s%s%s%s" % (
- Warns, userTime,
- Instagram, Reddit, Steam, Location, Soundcloud, Snapchat, PSN, XBOX),
- parse_mode="markdown", disable_web_page_preview=True)
- if "hi bot" in message:
- bot.sendMessage(chat_id, "Hi, " + usersName + "!")
- if messageType == "private":
- if "/start" in message:
- bot.sendMessage(chat_id, "Hello, " + usersName + ". I am Imma Bot, and I am a multi-purpose chat bot! For updates, follow @ImmaBotDev. To see my commands, use /commands. To send feedback, use '/feedback <message>'")
- if "/help" in message:
- bot.sendMessage(chat_id, "Commands:\n/roll and /roll2\n/read\n/detect\n/listen\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/me\n/equalize\n/sharpen\n/invert\n/equalize\n\nAdmin Commands:\n/limit (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/antibot doesn't allow bots into the group\n/lock locks the group\n/nomedia restricts any media messages(reply to user)")
- def sticker():
- if 'reply_to_message' in msg:
- try:
- Bot.send_chat_action(chat_id, action=telegram.ChatAction.TYPING)
- file_id = msg['reply_to_message']['photo'][-1]['file_id']
- filename = str(msg['reply_to_message']['from']['id']) + ".png"
- bot.download_file(file_id, filename)
- im = Image.open(filename)
- im.thumbnail((512, 512))
- im.save("1" + filename)
- bot.sendDocument(chat_id, open("1" + filename, "rb"))
- os.remove(filename)
- os.remove("1" + filename)
- except:
- bot.sendMessage(chat_id, "Error occured")
- else:
- bot.sendMessage(chat_id, "Reply to a photo.")
- if "/stick" in message:
- if stickerExecute == True:
- t = threading.Thread(target=sticker)
- t.start()
- else:
- stickerExecute = True
- if "/forget" in message:
- if os.path.isfile("data/n" + str(messageFromID) + ".txt") == True:
- bot.sendMessage(chat_id, "_Your name has been forgotten_", parse_mode="markdown")
- os.remove("data/n" + str(messageFromID) + ".txt")
- if messageType != 'private':
- if "True" in open(str(chat_id) + "/data/8ball.txt", "r"):
- if "/magic8 " in message:
- if str(msg['text'][8:]).startswith('will'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][8:]).startswith('can'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][8:]).startswith('is'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][8:]).startswith('are'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][8:]).startswith('does'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][8:]).startswith('has'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- else:
- bot.sendMessage(chat_id, (random.choice(eightball)),
- reply_to_message_id=msg['message_id'])
- if message == "/magic8":
- bot.sendMessage(chat_id, '/magic8 <question>')
- if message == '/m8':
- bot.sendMessage(chat_id, "/m8 <question>")
- if message == '/m8@ImmaChatBot':
- bot.sendMessage(chat_id, "/m8 <question>")
- if message.startswith("/m8 "):
- if str(msg['text'][4:]).startswith('will'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('can'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('r '):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('should'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('would'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('is'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('how big'):
- bot.sendMessage(chat_id, "I don't know, I haven't seen how big it is.")
- elif str(msg['text'][4:]).startswith('how long'):
- bot.sendMessage(chat_id, "I don't know, I haven't seen how long it is.")
- elif str(msg['text'][4:]).startswith('are'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('does'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('did'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('am'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('kiss'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('has'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('when'):
- bot.sendMessage(chat_id, (random.choice(smartball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]).startswith('what tim'):
- bot.sendMessage(chat_id, (random.choice(smartball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]) == 'right':
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][4:]) == 'right?':
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif "don't you" in str(msg['text'][4:]):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif "dont you" in str(msg['text'][4:]):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- else:
- bot.sendMessage(chat_id, (random.choice(eightball)),
- reply_to_message_id=msg['message_id'])
- if message.startswith("/8ball "):
- if str(msg['text'][7:]).startswith('will'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('can'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('r '):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('should'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('would'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('is'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('how big'):
- bot.sendMessage(chat_id, "I don't know, I haven't seen how big it is.")
- elif str(msg['text'][7:]).startswith('how long'):
- bot.sendMessage(chat_id, "I don't know, I haven't seen how long it is.")
- elif str(msg['text'][7:]).startswith('are'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('does'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('did'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('am'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('kiss'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('has'):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('when'):
- bot.sendMessage(chat_id, (random.choice(smartball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]).startswith('what tim'):
- bot.sendMessage(chat_id, (random.choice(smartball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]) == 'right':
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif str(msg['text'][7:]) == 'right?':
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif "don't you" in str(msg['text'][7:]):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- elif "dont you" in str(msg['text'][7:]):
- bot.sendMessage(chat_id, (random.choice(easyeightball)),
- reply_to_message_id=msg['message_id'])
- else:
- bot.sendMessage(chat_id, (random.choice(eightball)),
- reply_to_message_id=msg['message_id'])
- def on_callback_query(msg):
- query_id, from_id, query_data = telepot.glance(msg, flavor='callback_query')
- if query_data == 'create_':
- keyboard = InlineKeyboardMarkup(
- inline_keyboard=[[InlineKeyboardButton(text="Cancel", callback_data='cancel_')]])
- bot.editMessageText(edited, "Alright, what would you like your username to be? (5-18 characters)", reply_markup=keyboard)
- open(str(msg['from']['id']) + "login.txt", "w").write("createusername")
- open(str(msg['from']['id']) + "data.txt", "w").write(str(msg['from']['id']))
- elif query_data == 'cancel_':
- os.remove(str(from_id) + "login.txt")
- bot.editMessageText(edited, "All operations have been canceled.")
- elif query_data == 'changepassword_':
- keyboard = InlineKeyboardMarkup(
- inline_keyboard=[[InlineKeyboardButton(text="Back", callback_data='Back_')]])
- open(str(msg['from']['id']) + "login.txt", "w").write("changepassword")
- bot.editMessageText(edited, "Enter your old password:", reply_markup=keyboard)
- elif query_data == 'logout_':
- if os.path.isfile('login/' + str(
- open('login/' + str(from_id) + 'LOGGED.txt').read()) + 'AUTH.txt'):
- if str(from_id) in open('login/' + str(
- open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AUTH.txt').read():
- bot.editMessageText(edited, "You have logged out of " + str(open("login/" + str(
- from_id) + "LOGGED.txt").read()) + '. 2-Auth has been deactivated.')
- if '1' in open('login/' + str(
- open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read():
- os.remove(
- 'login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt')
- os.remove("login/" + str(open("login/" + str(from_id) + "LOGGED.txt").read()) + "AUTH.txt")
- os.remove("login/" + str(from_id) + "LOGGED.txt")
- else:
- aadd = int(str(open('login/' + str(
- open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) - 1
- open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt',
- 'w').write(str(aadd))
- else:
- if '1' in open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt",
- 'r').read()) + 'AMOUNT.txt').read():
- os.remove('login/' + str(open("login/" + str(from_id) + "LOGGED.txt",
- 'r').read()) + 'AMOUNT.txt')
- else:
- aadd = int(str(open('login/' + str(
- open("login/" + str(from_id) + "LOGGED.txt",
- 'r').read()) + 'AMOUNT.txt').read())) - 1
- open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt",
- 'r').read()) + 'AMOUNT.txt', 'w').write(str(aadd))
- bot.editMessageText(edited, "You have logged out of " + str(
- open("login/" + str(from_id) + "LOGGED.txt").read()) + '.')
- os.remove("login/" + str(from_id) + "LOGGED.txt")
- else:
- bot.editMessageText(edited, "You have logged out of " + str(
- open("login/" + str(from_id) + "LOGGED.txt").read()) + '.')
- if '1' in open('login/' + str(
- open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read():
- os.remove('login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt')
- os.remove("login/" + str(from_id) + "LOGGED.txt")
- else:
- aadd = int(str(open('login/' + str(
- open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt').read())) - 1
- open('login/' + str(open("login/" + str(from_id) + "LOGGED.txt", 'r').read()) + 'AMOUNT.txt',
- 'w').write(str(aadd))
- else:
- bot.editMessageText(edited, "please..",
- parse_mode="markdown")
- print(str(open("token.dat", "r").read()))
- with open(os.path.dirname(os.path.realpath(__file__)) + '/token.dat') as file:
- TOKEN = file.readline().strip()
- bot = telepot.Bot(TOKEN)
- Bot = telegram.Bot(TOKEN)
- #bot.message_loop(handle)
- bot.message_loop(handle)
- while 1:
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement