Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, RegexHandler, Handler
- import psycopg2 as sql
- import telegram
- #import os
- ############################################################ Инициализация
- up = Updater("763589555:AAELoW39YwQFEGHVX8Uk1aBxhSIsE5Q2SvQ")
- dp = up.dispatcher
- conn=sql.connect(host="ec2-54-247-82-210.eu-west-1.compute.amazonaws.com",
- dbname="d4m8tmi7uq08i",user="xsbnkpmygiimfd",
- password="fcab0544cc54a0f3af9d75c339ef1adac60f41716454fabca95853c331e02614")
- cur=conn.cursor()
- ############################################################
- #ID
- conf=-367886782
- my=61174279
- logs=-1001354716839
- bot_id=up.bot.id
- def check_id(id):
- cur.execute("SELECT id from user_data2;")
- datat=cur.fetchall()
- if (id,) not in datat:
- cur.execute("INSERT into user_data2 VALUES({0});".format(id))
- conn.commit()
- def add_ban(id):
- cur.execute("INSERT into ban_list VALUES({0});".format(id))
- conn.commit()
- def start(bot,up):
- up.message.reply_text("Пиши что хочешь."+
- "Я пока рубаю андертейл. Если не выкладываю - значит цензура или бессмысленное сообщение")
- def conf_callback(bot,up):
- if up.message.text=="Block User":
- bot.sendMessage(conf,"Введите id пользователя",reply_markup=force)
- if up.message.reply_to_message.text=="Введите id пользователя":
- bot.sendMessage(conf,"Id={0}".format(up.message.text))
- if up.message.reply_to_message.from_user.id==bot_id :#Обработка ответа юзеру
- #bot.forwardMessage(logs, up.message.chat.id, up.message.message_id)# Пересылка в архив logs
- if up.message.text is not None: #Обработка текста
- bot.sendMessage(up.message.reply_to_message.forward_from.id,up.message.text)
- elif up.message.voice :#Обработка голоса
- bot.sendVoice(up.message.reply_to_message.forward_from.id,up.message.voice)
- elif up.message.photo :#Оработка фото
- bot.sendPhoto(up.message.reply_to_message.forward_from.id,up.message.photo[0],caption=up.message.caption)
- def user_chat(bot, up):#Обработка чата с юзером
- if up.message.chat.id != conf:
- bot.forwardMessage(conf, up.message.chat.id, up.message.message_id) #Пересылка в конфу
- #bot.forwardMessage(logs, up.message.chat.id, up.message.message_id) #Пересылка в архив logs
- if ((up.message.forward_from is not None)or(up.message.forward_from_chat is not None)): #проверка на наличие forward
- bot.sendMessage(conf,"^Sender: @{}".format(up.message.from_user.username)) # Пересылка username отправителя в конфу
- #bot.sendMessage(logs,"^Sender: @{}".format(up.message.from_user.username)) #Пересылка username отправителя в архив logs
- check_id(up.message.chat.id)
- def admin(bot,up):
- bot.sendMessage(up.message.chat.id,"Доступ к панели администратора получен",reply_markup=admin_panel)
- cur.execute("SELECT id from user_data2;")
- datat=cur.fetchall()
- test=str(datat)
- up.message.reply_text("Admin panel beta test")
- bot.sendMessage(conf,"Admin alert @"+str(up.message.chat.username))
- if up.message.chat.id==conf:
- bot.sendMessage(conf,test)
- ############################################### Клавиатуры
- keyb=[["Block User","button 2"],["button 3","button 4"]] #Custom keyboard
- admin_panel=telegram.ReplyKeyboardMarkup(keyb,resize_keyboard=True,one_time_keyboard=True)
- force=telegram.ForceReply() #force reply_markup
- remove=telegram.ReplyKeyboardRemove
- ################################################ Инициализация
- start = CommandHandler("start", start)
- admin = CommandHandler("admin",admin)
- conf_handler=MessageHandler(Filters.chat(conf),conf_callback)
- user = MessageHandler(Filters.all, user_chat)
- dp.add_handler(admin)
- dp.add_handler(conf_handler)
- dp.add_handler(start)
- dp.add_handler(user)
- a = up.start_polling()
- #webhook settings
- #PORT = int(os.environ.get('PORT', '5000'))
- #TOKEN="721715826:AAHM8yvAY2oh44IEYMi-a5Kw4ooULWxIS3I"
- #up.start_webhook(listen='0.0.0.0', port=PORT, url_path=TOKEN)
- #up.bot.set_webhook("https://confession-bot-py.herokuapp.com/721715826:AAHM8yvAY2oh44IEYMi-a5Kw4ooULWxIS3I")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement