def Cheak_code(message): bot = Bot() status = bot.sendChatAction(message["chat"]["id"], "typing") if cheak(): bot.sendMessage(message["chat"]["id"], "喵没码") else: bot.sendMessage(message["chat"]["id"], "买码惹")
def Translate(message): bot = Bot() with open(bot.plugin_dir + "Translate/__init__.py", encoding="utf-8") as f: h = f.readline()[1:] if len(message["text"]) < len(h) + 1: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "翻译失败!%0A要翻译的内容为空!", parse_mode="HTML", reply_to_message_id=message["message_id"]) return False elif message["text"][len(h) - 1] != ':': status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "翻译失败!%0A请检查分隔符是否为' : '!", parse_mode="HTML", reply_to_message_id=message["message_id"]) return False url = "http://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i=" words = ubp.quote(message["text"][len(h):]) headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36 Edg/83.0.478.37", "Host": "fanyi.youdao.com" } req = requests.get(url + words, headers=headers) #urlencode编码 types = { "ZH_CN2EN": "中文 » 英语", "ZH_CN2JA": "中文 » 日语", "ZH_CN2KR": "中文 » 韩语", "ZH_CN2FR": "中文 » 法语", "ZH_CN2RU": "中文 » 俄语", "ZH_CN2SP": "中文 » 西语", "EN2ZH_CN": "英语 » 中文", "JA2ZH_CN": "日语 » 中文", "KR2ZH_CN": "韩语 » 中文", "FR2ZH_CN": "法语 » 中文", "RU2ZH_CN": "俄语 » 中文", "SP2ZH_CN": "西语 » 中文" } type_ = req.json().get("type") result = "" for paragraph in req.json().get("translateResult"): for sentence in paragraph: result += sentence["tgt"] result += "%0A" #print(type_, result) status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], text="<b>" + types[type_] + "</b>%0A%0A" + result, parse_mode="HTML", reply_to_message_id=message["message_id"])
def ID(message): bot = Bot() status = bot.sendChatAction(message["chat"]["id"], "typing") if str(message["from"]["id"]) == config["root"]: status = bot.sendChatAction(message["chat"]["id"], "typing") bot.sendMessage(message["chat"]["id"], "主人," + "您的用户ID为:<b>" + str(message["from"]["id"]) + "</b>", parse_mode="HTML", reply_to_message_id=message["message_id"]) else: status = bot.sendChatAction(message["chat"]["id"], "typing") bot.sendMessage(message["chat"]["id"], str(message["from"]["first_name"]) + "%0A您的用户ID为:<b>" + str(message["from"]["id"]) + "</b>", parse_mode="HTML", reply_to_message_id=message["message_id"])
def Top(message): if str(message["from"]["id"]) != config["root"]: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "权限不足!", "html") elif str(message["from"]["id"]) == config["root"]: bot = Bot() url = "" data = {"Key": ""} with open(bot.plugin_dir + "Top/key.ini", "r") as f: sets = f.readlines() url = sets[0].strip() data["Key"] = sets[1].strip() status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "主人,正在获取服务器信息,请稍等...", "html") req = requests.post(url=url, data=data) if req.json().get("status") == False: req.close() status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "抱歉主人,获取服务器信息失败", "HTML") elif req.json().get("status") == True: contents = req.json().get("contents") Top = contents.get("Top") Cpu = contents.get("Cpu") Memory = contents.get("Memory") Swap = contents.get("Swap") Hostname = contents.get("Hostname") top_time = Top["top_time"] top_up = Top["top_up"] top_load_average = Top["top_load_average"] top_user = Top["top_user"] cpu_id = Cpu["cpu_id"] memory_total = Memory["memory_total"] avail_memory = Swap["avail_memory"] Cpu_temperature = contents.get("Cpu_temperature") Hard_disk = contents.get("Hard_disk") hd_total = Hard_disk[0] hd_avail = Hard_disk[1] msg = "<b>服务器:" + str(Hostname) + "</b>%0A" + \ "查询时间:<i>" + str(top_time) + "</i>%0A%0A" + \ "登入用户:<b>" + str(top_user) + "</b> 个%0A" + \ "运行时间:<b>" + str(top_up) + "</b>%0A" + \ "平均负载:<b>" + str(top_load_average[0]) + " " + str(top_load_average[1]) + " " + str(top_load_average[2]) + "</b>%0A" + \ "CPU温度:<b>" + str(Cpu_temperature) + " ℃</b>%0A" + \ "CPU用量:<b>" + str(round(100.0-float(cpu_id), 2)) + "</b> 已用,<b>" + str(round(float(cpu_id), 2)) + "</b> 空闲%0A" + \ "内存用量:<b>" + str(round((float(memory_total)-float(avail_memory))/1024, 2)) + "G</b> 已用,<b>" + str(round(float(avail_memory)/1024,2)) + "G</b> 空闲%0A" + \ "硬盘用量:<b>" + str(int(float(hd_total)-float(hd_avail))) + "G</b> 已用,<b>" + str(hd_avail) + "G</b> 空闲" status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], msg, "HTML")
def ID(message): bot = Bot() status = bot.sendChatAction(message["chat"]["id"], "typing") if str(message["from"]["id"]) == config["root"]: bot.sendMessage(message["chat"]["id"], "尊敬的主人" + "%0A您的用户ID为:" + str(message["from"]["id"]), "html") else: bot.sendMessage( message["chat"]["id"], str(message["from"]["first_name"]) + "%0A您的用户ID为:" + str(message["from"]["id"]), "html")
def Menu(message): bot = Bot() plugin_list = bot.plugin_bridge.values() menu_str = "" for plugin in plugin_list: with open(bot.plugin_dir + plugin + r"/__init__.py", encoding="utf-8") as f: line_1 = "" line_2 = "" for i in range(2): if i == 0: line_1 = f.readline().strip()[1:] elif i == 1: line_2 = f.readline().strip()[1:] menu_str += line_1 + " - " + line_2 + "%0A%0A" menu_str = "===== Command Menu =====%0A%0A" + menu_str + "%0A%0Av" + bot.VERSION status = bot.sendMessage(message["chat"]["id"], menu_str, "html")
def Menu(message): bot = Bot() plugin_list = bot.plugin_bridge.values() menu_str = "" for plugin in plugin_list: with open(bot.plugin_dir + plugin + r"/__init__.py", encoding="utf-8") as f: line_1 = "" line_2 = "" for i in range(2): if i == 0: line_1 = f.readline().strip()[1:] elif i == 1: line_2 = f.readline().strip()[1:] menu_str += "<b>" + line_1 + "</b> - " + line_2 + "%0A%0A" menu_str = "<b>===== Command Menu =====</b>%0A%0A" + menu_str + "%0A%0Av" + bot.VERSION status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], menu_str, parse_mode="HTML", reply_to_message_id=message["message_id"])
def Menu(message): bot = Bot() plugin_list = bot.plugin_bridge.values() menu_str = "" for plugin in plugin_list: with open(bot.plugin_dir + plugin + r"/__init__.py", encoding="utf-8") as f: line_1 = "" line_2 = "" for i in range(2): if i == 0: line_1 = f.readline().strip()[1:] elif i == 1: line_2 = f.readline().strip()[1:] menu_str += "<b>" + line_1 + "</b> - " + line_2 + "%0A%0A" menu_str = "<b>===== Command Menu =====</b>%0A%0A" + menu_str + "%0A%0A" + "开源地址:https://github.com/southcat/telebot-invitecode" status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], menu_str, "HTML")
def Chat(message): bot = Bot() url = "http://api.qingyunke.com/api.php?key=free&appid=0&msg=" url1 = "https://api.ownthink.com/bot?spoken=" requests.adapters.DEFAULT_RETRIES = 5 hello = ("你好", "nihao", "hello", "Hello", "HELLO", "hi", "Hi", "HI", "早上好", "上午好", "下午好", "晚上好", "中午好", "good morning", "Good morning", "good afternoom", "Good afternoom", "good evening", "Good evening") if message["text"][1:] in hello: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendVoice(message["chat"]["id"], bot.plugin_dir + "Chat/hello.ogg") else: req = requests.get(url + ubp.quote(message["text"][1:])) #urlencode编码 req.keep_alive = False req.encoding = "utf-8" status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], str(req.json().get("content").replace("{br}", "%0A")), "HTML")
def Firefoxmoniter(message): bot = Bot() with open(bot.plugin_dir + "Firefoxmoniter/__init__.py", encoding="utf-8") as f: h = f.readline()[1:] if len(message["text"]) < len(h): status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "查询失败!%0A邮件地址为空!", "HTML") return False email = message["text"][len(h) - 1:] if all(['@' in email, '.' in email.split('@')[1]]): ehash = hashlib.sha1(email.encode("utf-8")) #经测试由sha1加密 emailhash = ehash.hexdigest() else: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "查询失败!%0A请检查邮件格式!", "HTML") return False if str(message["from"]["id"]) == config["root"]: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "主人,正在查询邮件地址[" + str(email) + "],请稍等...", "HTML") else: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "正在查询邮件地址" + str(email) + ",请稍等...", "HTML") protocol, ip, port = get_ip() proxies = {protocol: protocol + '://' + ip + ':' + port} url = "https://monitor.firefox.com/" r_session = requests.Session() page = r_session.get(url, proxies=proxies) if not page.status_code == requests.codes.ok: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "查询失败!%0A操作过于频繁,请稍后再试!", "text") return False page.encoding = "utf-8" session = page.cookies["session"] soup = BeautifulSoup(page.text, "lxml") csrf = soup.find_all("input")[0]["value"] url = "https://monitor.firefox.com/scan" data = {'_csrf': csrf, 'email': email, 'emailHash': emailhash} headers = { 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8', 'cookie': 'session=' + session + "; _ga=GA1.3.1750251620.1566005038; _gid=GA1.3.1329192982.1566005038; _gat=1;", 'origin': 'https://monitor.firefox.com', 'referer': 'https://monitor.firefox.com/', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36', } page = r_session.post(url, data=data, headers=headers, proxies=proxies) page.encoding = "utf-8" result = "" soup = BeautifulSoup(page.text, "lxml") if "扫描结果" in soup.find("title").text: result += "电子邮件地址" + email + "出现在" + str( soup.find("span", class_="bold").text) + "次已知数据外泄事件中。%0A%0A" for section in soup.find_all("div", class_="flx flx-col"): source = section.find_all("span")[0].text + "%0A" date = "事件记录时间:%0A" + section.find_all("span")[2].text + "%0A" data = "泄露的数据:%0A" + section.find_all("span")[4].text + "%0A" result += source + date + data + "%0A" status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], result, "html") else: status = bot.sendChatAction(message["chat"]["id"], "typing") status = bot.sendMessage(message["chat"]["id"], "查询失败!%0A请检测命令格式!", "text")