-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoboyDoor.py
More file actions
41 lines (31 loc) · 1.1 KB
/
RoboyDoor.py
File metadata and controls
41 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
import time
import telepot
import random
from os import listdir
from os.path import join, dirname, isfile, realpath
from telepot.loop import MessageLoop
from pprint import pprint
from playsound import playsound
import urllib.request
import json
confDict
with open(join(dirname(realpath(__file__)), 'conf.json')) as fp:
confDict = json.load(fp)
BotAuthCode = confDict['botAuthCode']
ChatTitles = ["Roboy Core Team", "开门啊", "Hack Roboy"]
RoboyOpenDoorSticker = "CAADAgADcwAD5dCAEEsvdJvjUpsSAg"
AudioDir = dirname(realpath(__file__))
AudioDir = join(AudioDir, "audios")
DoorOpenerIp = confDict['openerIp']
audioFiles = [f for f in listdir(AudioDir) if isfile(join(AudioDir, f))]
l = range(0, len(audioFiles))
def handle(msg):
contentType, chatType, chatId = telepot.glance(msg)
if (chatType in ["group", "supergroup"] and (msg["chat"]["title"] in ChatTitles)):
if contentType == "sticker" and msg["sticker"]["file_id"] == RoboyOpenDoorSticker:
playsound(join(AudioDir, audioFiles[random.choice(l)]))
bot = telepot.Bot(BotAuthCode)
MessageLoop(bot, handle).run_as_thread()
while 1:
time.sleep(10)