Skip to content

Instantly share code, notes, and snippets.

@sae13
Created August 4, 2020 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sae13/7c22b70d62cc7d825b389822aa70c1ee to your computer and use it in GitHub Desktop.
Save sae13/7c22b70d62cc7d825b389822aa70c1ee to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler, StringRegexHandler, BaseFilter)
from telegram import MessageEntity
import logging
group_admins = {}
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
class CaptionUrlType(BaseFilter):
def filter(self,message):
print(1)
try:
return 'http' in message.caption
print('http' in message.caption)
print(2)
except:
return False
captionurltype = CaptionUrlType()
def start(bot, update):
if update.message.chat.type == 'private':
update.message.reply_text(
"Hi there, I have One simple Job in Groups, deleting apk s from group "
"\n add me as Group Admin And I`ll delete any APK files are coming In your Group"
"\n My God : Http://t.me/saeb_m"
"\n yoU can find my Source in : http://sae13.ir")
def delmsg(bot,update):
print("delmsg is functional")
try:
print (update.message.text)
except:
pass
if update.message.chat.type != 'private':
tmp_admins = bot.getChatAdministrators(update.message.chat_id)
tmp_admins_ids = []
group_admins[update.message.chat_id]=[]
for i in tmp_admins:
tmp_admins_ids.append(i.user.id)
if update.message.from_user.id not in tmp_admins_ids:
bot.deleteMessage(update.message.chat_id , update.message.message_id)
#'فوق العاده ترین اپلیکیشنی که تا الان نصب کردم! از دستش ندید ☝🏻☝🏻☝🏻'
def error(bot, update, error):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s"', update, error)
def apkdel(bot, update):
try:
print(update.message.text)
except:
pass
if update.message.chat.type != 'private':
global group_admins
tmp_admins = bot.getChatAdministrators(update.message.chat_id)
tmp_admins_ids = []
group_admins[update.message.chat_id]=[]
for i in tmp_admins:
tmp_admins_ids.append(i.user.id)
if update.message.from_user.id not in tmp_admins_ids:
#print (update.message)
if update.message.document.mime_type == 'application/vnd.android.package-archive':
bot.deleteMessage(update.message.chat_id, update.message.message_id)
bot.restrictChatMember(update.message.chat_id, update.message.from_user.id)
else:
print(update.message)
def ppprint(bot,update):
try:
print(update.message)
print(update.caption)
except:
print("I tried to print:(")
def adds_delete(bot,update):
global group_admins
adds_keys=['خرید سریع', 'پرداخت درب منزل','بمال','سخسیه','🔞']
tmp_admins = bot.getChatAdministrators(update.message.chat_id)
tmp_admins_ids = []
group_admins[update.message.chat_id]=[]
for i in tmp_admins:
tmp_admins_ids.append(i.user.id)
if update.message.from_user.id not in tmp_admins_ids:
for i in adds_keys:
if update.message.caption.find(i) != -1:
bot.deleteMessage(update.message.chat_id, update.message.message_id)
def main():
# Create the Updater and pass it your bot's token.
#TOKEN="408413304:AAE4ZTfDBVM3mnAtVzxDBT9xhhmHDk5T352UM" # saeb_robot
TOKEN = "339429184:AAGvTewuR6NwVjdG8eXQlgggg-7KxdKUGrQ" #apkdelbot
updater = Updater(TOKEN)
adds_keys=['خرید سریع', 'پرداخت درب منزل','بمال','سخسیه','🔞']
# Get the dispatcher to register handlers
dp = updater.dispatcher
# Add conversation handler with the states GENDER, PHOTO, LOCATION and BIO
dp.add_handler(CommandHandler("start",start))
dp.add_handler(MessageHandler(Filters.document,apkdel))
dp.add_handler(MessageHandler( captionurltype,
callback = delmsg))
#dp.add_handler(MessageHandler((Filters.forwarded & Filters.photo) ,adds_delete))
dp.add_handler(MessageHandler(Filters.entity(MessageEntity.URL)\
| Filters.entity(MessageEntity.TEXT_LINK),delmsg))
dp.add_handler(RegexHandler(pattern = ".*🔞.*",callback = delmsg))
dp.add_handler(RegexHandler(pattern = ".*فوق العاده ترین اپلیکیشنی.*",callback = delmsg))
dp.add_handler(RegexHandler(pattern = ".*امکاناته.*",callback = delmsg))
for i in adds_keys:
dp.add_handler(RegexHandler(pattern = ".*{}.*".format(i),callback = delmsg))
dp.add_handler(MessageHandler(Filters.all, ppprint))
# dp.add_handler
# log all errors
dp.add_error_handler(error)
# Start the Bot
updater.start_polling()
# Run the bot until you press Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.idle()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment