Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- from random import randint
- import datetime
- import schedule
- import time
- import psycopg2
- import os
- DATABASE_URL = os.environ['DATABASE_URL']
- conn = psycopg2.connect(DATABASE_URL, sslmode='require')
- #test
- #bot = telebot.TeleBot('')
- # main
- bot = telebot.TeleBot('')
- # какое-та гавно
- # bot = telebot.TeleBot('')
- print('bot started')
- def send_CW_time():
- print("sended CW msg at", get_now_time())
- id = bot.send_message(def_chats, "Через один час ЧВ").message_id
- bot.pin_chat_message(def_chats, id, False)
- def edit_pinned_message_id(mes_id):
- pinned_message_idi = 0
- pinned_message_idi = mes_id
- return pinned_message_idi
- roman = 374085219
- def_chats = -1001412560727
- # write_id_chat = 0
- pinned_message_id = 0
- def find_message_id(pined_message):
- idi = str()
- i = 39
- while pined_message[i] != ',':
- idi = idi + pined_message[i]
- i += 1
- return idi
- def get_now_time():
- now = datetime.datetime.now()
- timee = now.strftime("%H:%M")
- return timee
- chats = ['-1001387587541', '-1001253655452', '-1001484947987']
- user_trigger = "@"
- send_messages_trigger = '/send_message_'
- command_trigger_group = "/group_join"
- command_trigger_auction = 'Список выставленных предметов на аукцион'
- command_trigger_pin2 = '.пин '
- command_trigger_pin3 = '.Пин '
- command_send_message_to = 'Отправь '
- command_trigger_exp_to_lvl = "Раса:"
- grace_trigger = '🎉🎉🎉Ты получил '
- allow_users_to_send_messages_by_bot = str(
- 'Ugadai_s_3_raz Denhom Ltataspb SixPathsOfMax MaxBratunin NeverAndFear alex_actionman Solijonov_Sh')
- allow_ids_to_send_messages_by_bot = str("")
- send_pin_messages_trigger = '/send_pin_message_'
- # adding_in_list(user_list)
- @bot.message_handler(commands=['start'])
- def send_welcome_message(message):
- print('@' + str(message.from_user.username), '/start')
- bot.reply_to(message, "pls, use /help to get more info about me")
- @bot.message_handler(commands=['ping_all'])
- def ping_all(message):
- new_msg = ''
- for i in range(len('/ping_all'), len(str(message.text))):
- new_msg += str(message.text)[i]
- if message.chat.id == -1001484947987:
- list_of_ping = '@Ugadai_s_3_raz @MaxBratunin @Solijonov_Sh @NeverAndFear @alex_actionman @SixPathsOfMax'
- bot.send_message(message.chat.id, new_msg + ' ' + list_of_ping)
- @bot.message_handler(commands=['help'])
- def send_welcome_message(message):
- print('@' + str(message.from_user.username), '/help')
- bot.reply_to(message, "I cant do anything! Kill me pls")
- bot.reply_to(message, "U can find more info")
- @bot.message_handler(commands=['nowtime'])
- def send_welcome_message(message):
- time = str(get_now_time())
- print('@' + str(message.from_user.username), '/nowtime at', time)
- bot.reply_to(message, time)
- @bot.message_handler(commands=['F'.lower()])
- def send_welcome_message(message):
- time = str(get_now_time())
- print('@' + str(message.from_user.username), '/f', time)
- bot.send_message(message.chat.id, '/F')
- # answer on /group_join
- @bot.message_handler(content_types=['text'])
- def send_messages(message):
- print(message.from_user.id)
- print(message.chat.id)
- print(message.from_user.username)
- global chat_ida
- global pinned_user_message_id
- global message_bot_sent_id
- pined_message = message
- a = str(message.text)
- if message.text == 'Сала Україні' or message.text == 'Сала Украине':
- print('heroi by @' + str(message.from_user.id))
- bot.reply_to(message, 'Героям сала!')
- if message.text == 'Бот извинись' or message.text == 'Бот, извинись':
- print('Извинения', '@' + str(message.from_user.username))
- sorry = str('Извините, ')
- sorry = sorry + '@' + str(message.from_user.username)
- bot.send_message(message.chat.id, sorry)
- if message.text == 'Бот заспам Максима Кадыровича':
- print('spam', str(message.from_user.username))
- loh = str(message.from_user.username)
- for i in range(2):
- bot.send_message(message.chat.id, '@' + loh + '\n')
- if message.text == 'Бот спокойной ночи' or message.text == 'Bot bb' or message.text == 'Бот, спокойной ночи':
- print('@' + str(message.from_user.username), 'good night')
- bot.reply_to(message, 'И тебе @' + message.from_user.username)
- if message.text == 'Бот, команды' or message.text == '/commands' or str(
- message.text).lower() == '/commands@Consta_bot'.lower():
- print('@' + str(message.from_user.username), 'commands')
- bot.reply_to(message,
- 'Бот, спокойной ночи' + '\n' + '/help' + '\n' + '/start' + '\n' + "Бот принимает сообщения с выставленными предметами на аукционе и возвращает ссылки для покупки" + '\n' + '.Пин + <any>' + '\n' + 'Отправка профиля из игры форвардом - вернет сообщение с оставшимся опытом')
- if message.chat.id == -1001387587541 or message.chat.id == -1001253655452 or message.chat.id == -1001484947987 or message.from_user.username == 'denhom' or message.from_user.username == 'Ugadai_s_3_raz' or message.from_user.id == 374085219 or message.from_user.username == 'Zhutkij_Tip' or message.from_user.id == 435794350 or message.chat.id == 304634959:
- if (a.find(command_trigger_group) != -1) and message.chat.pinned_message != message.text and message.chat.id == -1001484947987:
- print('@' + str(message.from_user.username), 'pin message', message.text)
- pined_message = str(pined_message)
- mess_id = find_message_id(pined_message)
- bot.pin_chat_message(message.chat.id, mess_id, False)
- bot.send_message(message.chat.id,
- "@Ugadai_s_3_raz @MaxBratunin @Solijonov_Sh @NeverAndFear @alex_actionman @SixPathsOfMax Народ, тут данж!")
- replacing_message = str(message.text)
- send_message = 'Держи и пользуйся! \n Список выставленных предметов на аукцион. Чтобы купить предмет, перешли в @rf_telegram_bot и кликни на команду напротив нужного лота. \n'
- if replacing_message.find(command_trigger_auction) != -1:
- print('replace auction ', '@' + str(message.from_user.username))
- into = []
- intro = str(replacing_message)
- for i in range(len(intro)):
- into.append(intro[i])
- check = str('return')
- count = 0
- while (int(intro.find(check)) != -1):
- place = int(intro.find(check))
- # print(*intro)
- if count > 0:
- place1 = place - 3 * count
- else:
- place1 = place
- for _ in range(6):
- intro = intro.replace(intro[place + _], 'Q', 1)
- del into[place1]
- into.insert(place1, 'b')
- into.insert(place1 + 1, 'u')
- into.insert(place1 + 2, 'y')
- count += 1
- for l in range(105, len(into)):
- send_message = send_message + into[l]
- bot.reply_to(message, send_message)
- # print(message)
- if a.find(command_trigger_pin2, 0, len(command_trigger_pin2)) != -1 or a.find(command_trigger_pin3, 0,
- len(command_trigger_pin3)) != -1:
- pinned_user_message_idi = message.message_id
- pinned_message_id = edit_pinned_message_id(message.message_id)
- pinned_user_message_id = message.message_id
- chat_ida = message.chat.id
- print(pinned_user_message_idi)
- print('@' + str(message.from_user.username), 'pin "', message.text, '"')
- bot_message = ''
- for z in range(len(command_trigger_pin2), len(a)):
- if z == len(command_trigger_pin2):
- bot_message += a[z].upper()
- else:
- bot_message += a[z]
- useless = str(bot.send_message(message.chat.id, bot_message).message_id)
- message_bot_sent_id = useless
- bot.pin_chat_message(message.chat.id, useless, False)
- if message.text == 'Кинь гифку' or message.text == '/gif' or str(
- message.text).lower() == '/gif@Consta_bot'.lower():
- num_of_gif = randint(1, 5)
- # num_of_gif = 1
- if num_of_gif == 1:
- bot.send_document(message.chat.id, 'https://media.giphy.com/media/XCm1DuH04vZ6KXIXh8/giphy.gif')
- if num_of_gif == 2:
- bot.send_document(message.chat.id, 'https://media.giphy.com/media/M8zyReUTgWeitlQI1G/giphy.gif')
- if num_of_gif == 3:
- bot.send_document(message.chat.id, 'https://media.giphy.com/media/kaHm4fBiIynYIkwwbD/giphy.gif')
- if num_of_gif == 4:
- bot.send_document(message.chat.id, 'https://media.giphy.com/media/jTBS0JwtWAeusllqiQ/giphy.gif')
- if num_of_gif == 5:
- bot.send_document(message.chat.id, 'https://media.giphy.com/media/TGLAvE48ERAJwFJMMh/giphy.gif')
- msg = str(message.text)
- if msg.find(command_trigger_exp_to_lvl, 0, len(command_trigger_exp_to_lvl) + 1) != -1 and message.forward_from != None:
- print(message.date,' ', message.forward_date, ' ', message.date - 60*5)
- if message.forward_from.id == 577009581:
- if message.date - 60*5 <= message.forward_date:
- print('Check exp by @' + str(message.from_user.username))
- place_exp = str(message.text).find("Опыт: ") + len("Опыт: ")
- end_exp = msg.find('🏵Аден:') - 2
- exp_mid = msg.find('/', place_exp, end_exp)
- now_exp = ''
- need_exp = ''
- for i in range(place_exp, exp_mid):
- now_exp = now_exp + msg[i]
- for j in range(exp_mid + 1, end_exp + 1):
- need_exp = need_exp + msg[j]
- print(need_exp, now_exp)
- need_exp = float(need_exp)
- now_exp = float(now_exp)
- now_exp = int(now_exp)
- exp = int(need_exp - now_exp)
- person = "@" + str(message.from_user.username)
- exp = str(exp)
- exp = exp[::-1]
- exp2 = ''
- print(exp)
- _ = 0
- while _ < len(exp):
- ii = _
- while ii < _ + 3 and ii != len(exp):
- exp2 = exp2 + exp[ii]
- ii += 1
- exp2 = exp2 + ' '
- _ += 3
- exp2 = exp2[::-1]
- print(exp2)
- msg_text = person + ' Тебе осталось' + str(exp2) + " 🌕опыта"
- bot.delete_message(message.chat.id, message.message_id)
- bot.send_message(message.chat.id, msg_text)
- else:
- bot.reply_to(message, 'Профиль не должен быть старше более 5 мин')
- if message.text.find(grace_trigger) != -1 and message.forward_from != None:
- if message.forward_from.id == 577009581:
- bot.reply_to(message, 'Грац!')
- if message.text.find(send_messages_trigger, 0, len(send_messages_trigger)) != -1:
- pos = len(send_messages_trigger)
- text = message.text
- send_text = text[pos+2::+1]
- print(*send_text, '\n', *text, '\n', text[pos])
- print(chats[2])
- if text[pos] == '1':
- bot.send_message(chats[0], send_text)
- if text[pos] == '2':
- bot.send_message(chats[1], send_text)
- if text[pos] == '3' and message.from_user.id == 374085219:
- bot.send_message(chats[2], send_text)
- if message.text.find(send_pin_messages_trigger, 0, len(send_messages_trigger)) != -1:
- pos = len(send_pin_messages_trigger)
- text = message.text
- send_text = text[pos + 2::+1]
- if text[pos] == '1':
- a = bot.send_message(chats[0], send_text).message_id
- bot.pin_chat_message(chats[0], a)
- if text[pos] == '2':
- a = bot.send_message(chats[1], send_text).message_id
- bot.pin_chat_message(chats[1], a)
- if text[pos] == '3' and message.from_user.id == 374085219:
- a = bot.send_message(chats[2], send_text).message_id
- bot.pin_chat_message(chats[2], a)
- else:
- bot.reply_to(message,
- 'У Вас недостаточно прав, обратитесь к @ugadai_s_3_raz или отправляйте сообщения в чаты АМг и АМГнг')
- print('fckn pidor @{} want to use bot'.format(str(message.from_user.username)))
- bot.send_message(374085219,
- '@{0} рвется юзать бота {1} UTC +0 в чате {2} "{3}" \n "{4}"'.format(str(message.from_user.username),
- time.strftime('%H:%M:%S'),
- message.chat.id,
- message.chat.title, message.text))
- # new chat member
- @bot.message_handler(content_types=['new_chat_members'])
- def greeting(message):
- bot.reply_to(message, "Приветствую, путник, проверь, стоит ли у тебя этот стикер пак?")
- bot.send_message(message.chat.id, "https://t.me/addstickers/BellatoOneLove")
- bot.send_sticker(message.chat.id, 'CAADAgADHQADYxZMFqbW_Sujed_7FgQ')
- # @bot.message_handler(commands = ['help', 'start'])
- # def answer_to_command(message):
- @bot.edited_message_handler(content_types=['text'])
- def edit_message(message):
- print('someone edit msg', '@' + str(message.from_user.username))
- edited_message = message.text
- # print('message.message_id', message.message_id, 'pinned_user_message_id', pinned_user_message_id)
- if str(message.text).find(command_trigger_pin3, 0, len(command_trigger_pin3)) != -1 or str(message.text).find(
- command_trigger_pin2, 0,
- len(command_trigger_pin2)) != -1:
- new_text = ''
- got_message = str(message.text)
- for i in range(4, len(got_message)):
- new_text = new_text + got_message[i]
- bot.edit_message_text(new_text, chat_ida, message_bot_sent_id)
- # schedule.every().day.at("8:00").do(send_CW_time)
- # schedule.every().day.at("13:00").do(send_CW_time)
- # schedule.every().day.at("18:00").do(send_CW_time)
- bot.polling(none_stop=True, interval=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement