Advertisement
pVinc

Untitled

May 27th, 2021
864
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from fbchat import Client
  2. from fbchat.models import *
  3. from datetime import date, datetime
  4. from signal import signal, SIGINT
  5. from sys import exit
  6. from time import time, sleep
  7. from math import sqrt
  8. from random import randint
  9.  
  10. #global settings
  11.  
  12. #Base Response Delay in [s]
  13. #BDR is double
  14. bdr = 1
  15.  
  16. #Message Reading Time Delay in [s]
  17. mrtd = 2
  18.  
  19. #Chance of Response
  20. #if randint < cor then true
  21. cor = 64
  22.  
  23. class NasraneCounter(Client):
  24.     def onLoggedIn(self, email):
  25.         self.startTime = time()
  26.         self.activityCounter = 0
  27.  
  28.     def onMessage(self, author_id, message_object, thread_id, thread_type, **kwargs):
  29.         sleep(bdr)
  30.         self.markAsDelivered(thread_id, message_object.uid)
  31.         self.markAsRead(thread_id)
  32.         sleep(bdr + max(0, sqrt(len(message_object.text)) - mrtd))
  33.         if randint(1, 100) < cor:
  34.             if message_object.text.casefold() == 'nasrane' and author_id != self.uid:
  35.                 self.send(message_object, thread_id=thread_id, thread_type=thread_type)
  36.                 self.activityCounter += 1
  37.    
  38.             if message_object.text.casefold().encode('ascii', errors='ignore') == "coś się kończy coś zaczyna".casefold().encode('ascii', errors='ignore'):
  39.                 self.send(Message(text="jebać disa skurwysyna"), thread_id=thread_id, thread_type=thread_type)
  40.                 self.activityCounter += 1
  41.    
  42.             if message_object.text.casefold() == "elegancko":
  43.                 self.send(Message(text="no i essa"), thread_id=thread_id, thread_type=thread_type)
  44.                 self.activityCounter += 1
  45.    
  46.             if message_object.text.casefold() == "xd" and message_object.text == "Xd":
  47.                 self.send(Message(text="Ty chyba jeżeś jakiś pojebany xd"), thread_id=thread_id, thread_type=thread_type)
  48.                 self.activityCounter += 1
  49.             elif message_object.text.casefold() == "xd" and author_id != self.uid:
  50.                 self.send(message_object, thread_id=thread_id, thread_type=thread_type)
  51.                 self.activityCounter += 1
  52.    
  53.             if message_object.text.casefold() == "ej":
  54.                 self.send(Message(text="Twōj stary gej"), thread_id=thread_id, thread_type=thread_type)
  55.                 self.activityCounter += 1
  56.    
  57.             if message_object.text.casefold() == "oj tak byczq" or message_object.text.casefold() == "oj tak tak byczq":
  58.                 self.send(Message(text="+1"), thread_id=thread_id, thread_type=thread_type)
  59.                 self.activityCounter += 1
  60.    
  61.             if message_object.text.casefold() == "oj nie byczq" or message_object.text.casefold() == "oj nie nie byczq":
  62.                 self.send(Message(text="-1"), thread_id=thread_id, thread_type=thread_type)
  63.                 self.activityCounter += 1
  64.    
  65.             if message_object.text.casefold() == "kurwa":
  66.                 self.send(Message(text="japierdole"), thread_id=thread_id, thread_type=thread_type)
  67.                 self.activityCounter += 1
  68.    
  69.             if message_object.text.casefold() == "japierdole" and author_id != self.uid:
  70.                 self.send(Message(text="przy pustym stole"), thread_id=thread_id, thread_type=thread_type)
  71.                 self.activityCounter += 1
  72.    
  73.             if message_object.text.casefold() == "hotel":
  74.                 self.send(Message(text="trivago"), thread_id=thread_id, thread_type=thread_type)
  75.                 self.activityCounter += 1
  76.    
  77.             if message_object.text.casefold().find("2137") > -1 or message_object.text.casefold().find("21:37") > -1:
  78.                 self.send(Message(text="Toż to papieżowa liczba :v"), thread_id=thread_id, thread_type=thread_type)
  79.                 self.activityCounter += 1
  80.  
  81.         if message_object.text.casefold() == "/help":
  82.             helptext = "NasraneCounter bot:\n/help - wypisz polecynia\n/status - status bota\n/lista - lista rzeczy do zabraniŏ"
  83.             self.send(Message(text=helptext), thread_id=thread_id, thread_type=thread_type)
  84.  
  85.         if message_object.text.casefold() == '/newtime' and thread_id == '3033198683462306':
  86.             self.changeThreadTitle("Dupnŏ Rajza ({} dni)".format((date(2020, 7, 5) - date.today()).days), thread_id=thread_id, thread_type=ThreadType.GROUP)
  87.             self.activityCounter += 1
  88.  
  89.         if message_object.text.casefold() == "wiela do rajzy" and thread_id == '3033198683462306':
  90.             nSeconds = 1593957600-time()
  91.             nHours = nSeconds/60/60
  92.             nDays = nHours/24
  93.             wiadomosc = "Ôstoło sie jeszcze {} dni, abo inakszy {} godzin, abo tyż {} sekund".format(round(nDays, 1), round(nHours, 1), round(nSeconds, 1))
  94.             self.send(Message(text=wiadomosc), thread_id=thread_id, thread_type=thread_type)
  95.             self.activityCounter += 1
  96.  
  97.         if message_object.text.casefold() == "/status":
  98.             self.activityCounter += 1
  99.             statusMessage = "[ {} ] Bot działŏ ôd {} sekund, i ôdpedzioł na {} poleceń. COR = {}, BDR = {}, MRTD = {}".format(time(), time() - self.startTime, self.activityCounter, cor, bdr, mrtd)
  100.             self.send(Message(text=statusMessage), thread_id=thread_id, thread_type=thread_type)
  101.  
  102.         if message_object.text.casefold() == "/lista":
  103.             self.send(Message(text="https://docs.google.com/spreadsheets/d/1aqFmbtObfaZeA5pFaCJvYen-WPdoYK2FVo_WBzgZXT0/edit#gid=0"), thread_id=thread_id, thread_type=thread_type)
  104.             self.activityCounter += 1
  105.  
  106.  
  107. client = NasraneCounter('alambinark@gmail.com', 'Nasrane12345')
  108.  
  109. def siginthndl(sig, frame):
  110.     print("CTRL-C Interrupt detected, halting...")
  111.     client.logout()
  112.     exit(0)
  113. signal(SIGINT, siginthndl)
  114.  
  115. client.listen()
  116.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement