Advertisement
Guest User

Untitled

a guest
May 19th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.89 KB | None | 0 0
  1. from pyrogram import Client, Filters, Emoji
  2.  
  3. import locale
  4. import time, schedule
  5. import threading
  6. import datetime
  7. import pytz
  8. import re
  9. import os
  10. import sys
  11. import psutil
  12. import logging
  13. from random import randint
  14. import random
  15.  
  16. app = Client(
  17. "Anatras02"
  18. )
  19.  
  20. locale.setlocale(locale.LC_TIME, "IT")
  21.  
  22. running = True
  23.  
  24. def startJob():
  25.     while running==True:
  26.         schedule.run_pending()
  27.         time.sleep(1)
  28.  
  29.  
  30. def job():
  31.     print("Primo!")
  32.     app.send_message(-1001217515072,"Primo")
  33.     app.send_message(-1001120221948,"Primo")
  34.     app.send_message(-1001275441008,"Primo")
  35.     app.send_message(-1001146498129,"Primo")
  36.     app.send_message(-1001257654240,"Primo")
  37.  
  38. def Buongiorno():
  39.     print("Buongiornissimo Kaffeeeee!1!!11!")
  40.     random.seed(datetime.datetime.now().minute)
  41.     randomBuongiorno=randint(1,3)
  42.     if randomBuongiorno==1:
  43.         app.send_message(270223153,"Buongiornissimo")
  44.     elif randomBuongiorno==2:
  45.         app.send_message(270223153,"Buondì")
  46.     else:
  47.         app.send_message(270223153,"Buongiorno"+Emoji.GRINNING_FACE_WITH_SMILING_EYES)
  48.  
  49.     app.send_message(-1001217515072,"Buongiorno "+Emoji.GRINNING_FACE_WITH_SMILING_EYES)
  50.  
  51.  
  52. schedule.every().day.at("15:00").do(job)
  53. schedule.every().day.at("21:15").do(Buongiorno)
  54.  
  55. t1 = threading.Thread(target=startJob)
  56. t1.start()
  57.  
  58. @app.on_message(Filters.me&Filters.command(["id"]))
  59. def getChatId(client,message):
  60.     app.send_message(message.chat.id,"Chat id: "+"`"+str(message.chat.id)+"`")
  61.  
  62. @app.on_message(Filters.command(["calcola"]))
  63. def Calcola(client,message):
  64.     rx = r'/calcola\s+((\d+)([/]?[*]?[+]?[-]?)(\d+))'
  65.     mo = re.match(rx,message.text)
  66.     if(mo):
  67.         app.send_message(message.chat.id,"Risultato: `"+str(eval(mo.group(1)))+"`")
  68.     else:
  69.         message.reply("Ao, formato sbagliato")
  70.  
  71. @app.on_message(Filters.me&Filters.command(["restart"]))
  72. def restart(client,message):
  73.     app.send_message(message.chat.id,"Mi sto riavviando "+Emoji.GRINNING_FACE_WITH_SMILING_EYES)
  74.  
  75.     try:
  76.         p = psutil.Process(os.getpid())
  77.         for handler in p.get_open_files() + p.connections():
  78.             os.close(handler.fd)
  79.     except Exception as e:
  80.         logging.error(e)
  81.  
  82.     python = sys.executable
  83.     os.execl(python, python, "\"{}\"".format(sys.argv[0]))
  84.  
  85. @app.on_message(Filters.command(["palindroma"]))
  86. def Palindroma(client,message):
  87.     rx=r'/palindroma\s+(\w+)'
  88.     mo=re.match(rx,message.text)
  89.     if mo:
  90.         mo.group(1)
  91.         if mo.group(1).lower() == mo.group(1).lower()[::-1]:
  92.             message.reply("La parola `"+mo.group(1)+"` **è** palindroma")
  93.         else:
  94.             message.reply("La parola `"+mo.group(1)+"` **non** è palindroma")
  95.  
  96.     else:
  97.         message.reply("Devi inserire una parola!")
  98.  
  99. @app.on_message(Filters.command(["orari"]))
  100. def Orario(client,message):
  101.     orarioLasVegas = datetime.datetime.now(pytz.timezone('America/Los_Angeles'))
  102.     orarioIta=datetime.datetime.now(pytz.timezone('Europe/Rome'))
  103.     app.send_message(message.chat.id,"Nel **Nevada, USA ** sono le "+str(orarioLasVegas.hour)+" e "+str(orarioLasVegas.minute)+" minuti del "+orarioLasVegas.strftime("%d %B"))
  104.     app.send_message(message.chat.id,"In **Italia** sono le "+str(orarioIta.hour)+" e "+str(orarioIta.minute)+" minuti del "+orarioIta.strftime("%d %B"))
  105.  
  106. @app.on_message(Filters.command(["dadoanatroso"]))
  107. def dado(client,message):
  108.     rx=r'/dadoanatroso\s+(\d+)'
  109.     mo=re.match(rx,message.text)
  110.     if mo:
  111.         dado=randint(1,int(mo.group(1)))
  112.         app.send_message(message.chat.id,"@"+message.from_user.username+" hai appena tirato un dado a **"+mo.group(1)+"** facce.\nÈ uscito il numero **"+str(dado)+"**")
  113.     else:
  114.         dado=randint(1,6)
  115.         app.send_message(message.chat.id,"@"+message.from_user.username+" hai appena tirato un dado a **6** facce.\nÈ uscito il numero **"+str(dado)+"**")
  116. app.run()
  117.  
  118. running = False
  119. t1.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement