Advertisement
Guest User

msgbot

a guest
Jan 24th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. import fbchat
  2. import time
  3. from datetime import datetime
  4.  
  5. #max 9 linijek
  6. wiad={
  7. 0: "1. 2. 3. 4. 5. 6. 7. 8. 9. ",
  8. 1: "jeden",
  9. 2: "dwa",
  10. 3: "czy",
  11. 4: "idk",
  12. 5: "idk",
  13. 6: "idk",
  14. 7: "idk",
  15. 8: "idk",
  16. 9: "idk",
  17. }
  18. #username = "" #input("Username: ")
  19. username = ""
  20. #password = "" #input("Tera daj haslo ")
  21. password = ""
  22. client = fbchat.Client(username, password)
  23. command = (input("Czy na pewno? (Y/N/tera/petla) ")) #chciany program dla komendy petla
  24. command.lower()
  25. if command == "y":
  26. czas1 = input("yyyy-mm-dd hh:mm:ss: ")
  27. print(czas1)
  28. while True:
  29. czas = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  30. print(czas)
  31. time.sleep(1)
  32. if czas == czas1:
  33. for i in range(3): #ile wiadomosci
  34. name = "Kacper Latecki" # input("Name: ")
  35. friends = client.searchForUsers(name)
  36. friend = friends[0]
  37. # msg = input("Message: ")
  38. msg = wiad[i]
  39. sent = client.send(fbchat.models.Message(text=msg), thread_id=friend.uid)
  40. time.sleep(20)
  41. else:
  42. break
  43. elif command == 'tera':
  44. for i in range(3):
  45. name = "Kacper Latecki" # input("Name: ")
  46. friends = client.searchForUsers(name)
  47. friend = friends[0]
  48. msg = wiad[i]
  49. sent = client.send(fbchat.models.Message(text=msg), thread_id=friend.uid)
  50. elif command == 'petla':
  51. czas1 = input("yyyy-mm-dd hh:mm:ss: ")
  52. print(czas1)
  53. while True:
  54. czas = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  55. print(czas)
  56. time.sleep(1)
  57. if czas == czas1:
  58. for x in range(2): #ile razy te wiadomosci
  59. time.sleep(60)
  60. for i in range(2): #ile wiadomosci
  61. name = "Kacper Latecki" # input("Name: ")
  62. friends = client.searchForUsers(name)
  63. friend = friends[0]
  64. msg = wiad[i]
  65. sent = client.send(fbchat.models.Message(text=msg), thread_id=friend.uid)
  66. time.sleep(30)
  67.  
  68. print('koniec')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement