SHARE
TWEET

Untitled

a guest Jun 19th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import telebot
  2. import code
  3. import json
  4. import random
  5. from flask import Flask, request
  6. server = Flask(__name__)
  7. TOKEN=code.token
  8.  
  9. def Molder():
  10.     with open ('glob.json','r',encoding='utf-8') as k:
  11.         glob=json.load(k)
  12.     a=random.choice(glob)
  13.     res=''
  14.     while True:
  15.         if res == '':
  16.             res+=a[0].capitalize()
  17.         else:
  18.             res+=a[0]
  19.         m1=a[2].keys()#znak prepinaniya
  20.         m1=list(m1)
  21.         m2=a[2].values()
  22.         m2=list(m2)
  23.         znak=random.choices(m1,weights=m2,k=1)
  24.         res+=znak[0]
  25.         if znak[0]!=' ':
  26.             res+=' '
  27.         m1=a[1].keys()#next word
  28.         m1=list(m1)
  29.         m2=a[1].values()
  30.         m2=list(m2)
  31.         a=random.choices(m1,weights=m2,k=1)[0]
  32.         for v in glob:
  33.             if v[0]==a:
  34.                 a=v
  35.                 break
  36.         if res[-2]=='.':
  37.             break
  38.     return(res)
  39. bot = telebot.TeleBot(TOKEN)
  40. @bot.message_handler(func=lambda m: True)    
  41. def sendtheword(message):
  42.     bot.send_message(message.chat.id,Molder())
  43. @server.route('/' + TOKEN, methods=['POST'])
  44. def getMessage():
  45.     bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
  46.     return "!", 200
  47. @server.route("/")
  48. def webhook():
  49.     bot.remove_webhook()
  50.     bot.set_webhook(url='https://finalemanale.herokuapp.com/' + TOKEN)
  51.     return "!", 200    
  52. if __name__ == '__main__':
  53.     server.debug = True
  54.     server.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5000)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top