Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1.  
  2. PASTEBIN
  3. new paste
  4. API tools faq deals
  5.  
  6. Guest User
  7. -
  8. Public Pastes
  9.  
  10. Untitled0 sec ago
  11. Untitled1 sec ago
  12. UntitledPython | 11 sec ago
  13. Untitled18 sec ago
  14. UntitledPython | 24 sec ago
  15. Shy legit config26 sec ago
  16. Untitled36 sec ago
  17. Untitled36 sec ago
  18.  
  19. daily pastebin goal
  20. 33%
  21. help support pastebin
  22. SHARE
  23. TWEET
  24. Untitled
  25. a guest Jul 21st, 2018 16 in 9 min
  26. Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  27. rawdownloadcloneembedreportprint Python 1.12 KB
  28.  
  29. # -*- coding: utf-8 -*-
  30. #coder :- Salman Faris
  31.  
  32. import sys
  33. import time
  34. import telepot
  35. import RPi.GPIO as GPIO
  36.  
  37. #LED
  38. def on(pin):
  39. GPIO.output(pin,GPIO.HIGH)
  40. return
  41. def off(pin):
  42. GPIO.output(pin,GPIO.LOW)
  43. return
  44.  
  45. # to use Raspberry Pi board pin numbers
  46. GPIO.setmode(GPIO.BCM)
  47. # set up GPIO output channel
  48. GPIO.setup(20, GPIO.OUT)
  49.  
  50. def handle(msg):
  51. chat_id = msg['chat']['id']
  52. command = msg['text']
  53.  
  54. print('Got command: %s' % command)
  55.  
  56. if command == 'halo':
  57. bot.sendMessage(chat_id, "🔐 Welcome to GATEMAN_Bot 🔐")
  58. elif command == 'On':
  59. bot.sendMessage(chat_id, on(20))
  60. elif command =='Off':
  61. bot.sendMessage(chat_id, off(20))
  62.  
  63. bot = telepot.Bot('606956685:AAEDJxdyi--cVYJ9ye-z7ChrGytjlVDKCcA')
  64. bot.deleteWebhook()
  65. bot.message_loop(handle)
  66. print('I am listening...')
  67.  
  68. while 1:
  69. try:
  70. time.sleep(10)
  71.  
  72. except KeyboardInterrupt:
  73. print('\n Program interrupted')
  74. GPIO.cleanup()
  75. exit()
  76.  
  77. except:
  78. print('Other error or exception occured!')
  79.  
  80. GPIO.cleanup()
  81.  
  82. RAW Paste Data
  83. # -*- coding: utf-8 -*-
  84. #coder :- Salman Faris
  85.  
  86. import sys
  87. import time
  88. import telepot
  89. import RPi.GPIO as GPIO
  90.  
  91. #LED
  92. def on(pin):
  93. GPIO.output(pin,GPIO.HIGH)
  94. return
  95. def off(pin):
  96. GPIO.output(pin,GPIO.LOW)
  97. return
  98.  
  99. # to use Raspberry Pi board pin numbers
  100. GPIO.setmode(GPIO.BCM)
  101. # set up GPIO output channel
  102. GPIO.setup(20, GPIO.OUT)
  103.  
  104. def handle(msg):
  105. chat_id = msg['chat']['id']
  106. command = msg['text']
  107.  
  108. print('Got command: %s' % command)
  109.  
  110. if command == 'halo':
  111. bot.sendMessage(chat_id, "🔐 Welcome to GATEMAN_Bot 🔐")
  112.  
  113. elif command == 'On': {
  114. bot.sendMessage(chat_id, "Enter Gateman key 🔑🔑")
  115. if command == 'mygate'{
  116. bot.sendMessage(chat_id, "Pintu terbuka 🔓🔓")
  117. bot.sendMessage(chat_id, on(20))
  118. }
  119. }
  120.  
  121. elif command =='Off':{
  122. bot.sendMessage(chat_id, "Enter Gateman key 🔑🔑")
  123. if command == 'mygate'{
  124. bot.sendMessage(chat_id, "Pintu terbuka 🔓🔓")
  125. bot.sendMessage(chat_id, on(20))
  126. }
  127. bot.sendMessage(chat_id, off(20))
  128. bot.sendMessage(chat_id, "Pintu tertutup 🔒🔒")
  129. }
  130.  
  131. bot = telepot.Bot('606956685:AAEDJxdyi--cVYJ9ye-z7ChrGytjlVDKCcA')
  132. bot.deleteWebhook()
  133. bot.message_loop(handle)
  134. print('I am listening...')
  135.  
  136. while 1:
  137. try:
  138. time.sleep(10)
  139.  
  140. except KeyboardInterrupt:
  141. print('\n Program interrupted')
  142. GPIO.cleanup()
  143. exit()
  144.  
  145. except:
  146. print('Other error or exception occured!')
  147. GPIO.cleanup()
  148. create new paste / dealsnew! / api / scraping api / syntax languages / archive / faq / tools / night mode / go
  149. privacy statement / cookies policy / terms of service / security disclosure / dmca / contact
  150.  
  151. By using Pastebin.com you agree to our cookies policy to enhance your experience.
  152. Site design & logo © 2018 Pastebin; user contributions (pastes) licensed under cc by-sa 3.0 -- Dedicated Server Hosting by Steadfast
  153. Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement