Skip to content

Instantly share code, notes, and snippets.

@dyigitpolat
Created September 15, 2020 14:43
Show Gist options
  • Select an option

  • Save dyigitpolat/f58d97fa5b1ae34d070e6460168b22d2 to your computer and use it in GitHub Desktop.

Select an option

Save dyigitpolat/f58d97fa5b1ae34d070e6460168b22d2 to your computer and use it in GitHub Desktop.
import logging
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram import Bot
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def start(update, context):
update.message.reply_text('Memurunuzu selamlayınız.')
def help_command(update, context):
update.message.reply_text('Help!')
messagecount = {}
def processMessage(update, context):
"""Process message."""
bot = Bot("TOKEN")
userid = update.effective_user.id
if( userid in messagecount ):
messagecount[userid] += 1
else:
messagecount[userid] = 1
if( messagecount[userid] > 4):
update.message.reply_text("bugün çok konuştun.")
if( messagecount[userid] > 5):
bot.delete_message(chat_id=update.message.chat_id, message_id=update.message.message_id)
def main():
updater = Updater("TOKEN", use_context=True)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(MessageHandler(Filters.status_update.new_chat_members, start))
dp.add_handler(CommandHandler("help", help_command))
dp.add_handler(MessageHandler(Filters.text & ~Filters.command, processMessage))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment