Last active
June 12, 2017 20:50
-
-
Save sae13/cf8ecdfb4ccf1119ac2c007cfb30d13d to your computer and use it in GitHub Desktop.
Telegram bot for generating password. http://t.me/passwdrobot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# | |
# Simple Bot to reply to Telegram messages. This is built on the API wrapper, see | |
# echobot2.py to see the same example built on the telegram.ext bot framework. | |
# This program is dedicated to the public domain under the CC0 license. | |
import logging | |
import telegram | |
from telegram.error import NetworkError, Unauthorized | |
from time import sleep | |
from random import sample | |
from khayyam import JalaliDatetime | |
update_id = None | |
bot_started = JalaliDatetime.now() | |
def main(): | |
global update_id | |
# Telegram Bot Authorization Token | |
bot = telegram.Bot('YOUR BOT TOKEN') | |
# get the first pending update_id, this is so we can skip over it in case | |
# we get an "Unauthorized" exception. | |
try: | |
update_id = bot.get_updates()[0].update_id | |
except IndexError: | |
update_id = None | |
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
while True: | |
try: | |
echo(bot) | |
except NetworkError: | |
sleep(1) | |
except Unauthorized: | |
# The user has removed or blocked the bot. | |
update_id += 1 | |
def echo(bot): | |
global update_id | |
# Request updates after the last update_id | |
for update in bot.get_updates(offset=update_id, timeout=10): | |
update_id = update.update_id + 1 | |
if update.message: # your bot can receive updates without messages | |
# Reply to the message | |
if update.message.text: | |
if update.message.text == "/start": | |
update.message.reply_text("باسلام و احترام.این بات پسورد میسازه.بهتره اول هر پسورد " | |
"یک پسورد پیش فرض خودتون رو اضافه کنید و برای حساب های مهمتون از این " | |
"روش استفاده نکنید." | |
"" | |
"عقیل دردا بلات بابت وی پی اس" | |
"\n" | |
"@WISxDOM" | |
"\n" | |
"سورس بات رو میتونید اینجا مشاهده کنید:" | |
"\n" | |
"https://sae13.ir/archives/585" | |
"\n" | |
"@saeb_m" | |
"\n" | |
"حالا یه چیزی بنویسید مثلا " | |
"\n" | |
"beepaste.io password") | |
break | |
if update.message.text.lower() == 'uptime' : | |
now_time = JalaliDatetime.now() | |
uptime = now_time - bot_started | |
days_uptime = uptime.seconds // (3600 * 24) | |
hours_uptime = (uptime.seconds % (3600 * 24)) // 3600 | |
minutes_uptime =((uptime.seconds % (3600 * 24)) % 3600) //60 | |
bot.send_message(update.message.chat.id,"مدت زمانی فعالیت بات:" | |
"\n " | |
"{} روز و" | |
"\n" | |
" {}ساعت " | |
"\n" | |
"{}دقیقه".format(days_uptime, | |
hours_uptime, | |
minutes_uptime)) | |
break | |
alpha = "qwertyuiop[]asdfghjkl;'zxcvbnm,./`1234567890-=~!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:ZXCVBNM<>?" | |
first = "".join(sample(alpha,8)) | |
secound = "".join(sample(alpha,15)) | |
third = "".join(sample(alpha,30)) | |
update.message.reply_text(update.message.text) | |
update.message.reply_text('{}\n{}\n{}\n'.format(first, secound, third)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment