Skip to content

Instantly share code, notes, and snippets.

@blueset
Created September 10, 2017 07:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save blueset/3fa622a245bd757509c7c0a4a67cbc54 to your computer and use it in GitHub Desktop.
Save blueset/3fa622a245bd757509c7c0a4a67cbc54 to your computer and use it in GitHub Desktop.
Utsushidasu Kagami ver 3
import telegram
import telegram.ext
import re
# Utsushidasu Kagami Bot v3
# With sticker removal and off-topic transfer.
# License: MIT
"""
Copyright 2017 Eana Hufwe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
MAIN_GRP = -1
DISSCUSSION_GRP = -1
DISSCUSSION_GRP_LNK = "https://t.me/joinchat/0"
def sticker_del(bot, update):
if update.message.chat_id == MAIN_GRP:
bot.delete_message(update.message.chat_id, update.message.message_id)
def off_topic(bot, update):
if update.message.chat_id == MAIN_GRP and re.search(r"off.?topic", update.message.text.lower()):
update.message.reply_to_message.reply_text("I've moved it to the [off-topic group](%s)." % DISSCUSSION_GRP_LNK, quote=True, parse_mode="markdown", disable_web_page_preview=True)
name = (update.message.reply_to_message.from_user.username and "@%s" % update.message.reply_to_message.from_user.username) or update.message.reply_to_message.from_user.first_name
msg = update.message.reply_to_message.text
bot.sendMessage(DISSCUSSION_GRP, "%s wrote:\n%s\n\n⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️" % (name, msg))
updater = telegram.ext.Updater(token="a:b")
dispatcher = updater.dispatcher
dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.filters.Filters.sticker, sticker_del))
dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.filters.Filters.reply and telegram.ext.filters.Filters.text, off_topic))
updater.start_polling()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment