コード例 #1
0
def Hello(message):
    #print("你好,世界!")
    bot = Bot()
    status = bot.sendChatAction(message["chat"]["id"], "typing")
    status = bot.sendPhoto(message["chat"]["id"],
                           bot.plugin_dir + "Hello/helloworld.png",
                           reply_to_message_id=message["message_id"])
コード例 #2
0
def Top(message):
    bot = Bot()
    if str(message["from"]["id"]) == config["root"]:
        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"], text="主人,正在获取服务器信息,请稍等...", parse_mode="HTML", reply_to_message_id=message["message_id"])
        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"], text="抱歉主人,获取服务器信息失败", parse_mode="HTML", reply_to_message_id=message["message_id"])
        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_time_head = top_time[0]
            top_time_tail = top_time[1]
            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_head) + " " + str(top_time_tail) + "</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"], text=msg, parse_mode="HTML", reply_to_message_id=message["message_id"])
    else:
        status = bot.sendChatAction(message["chat"]["id"], "typing")
        status = bot.sendMessage(message["chat"]["id"], text="您没有权限!", parse_mode="HTML", reply_to_message_id=message["message_id"])
コード例 #3
0
ファイル: ID.py プロジェクト: GrassBlock1/teelebot
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"])
コード例 #4
0
ファイル: Translate.py プロジェクト: GrassBlock1/teelebot
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"])
コード例 #5
0
ファイル: Menu.py プロジェクト: southcat/teelebot
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")
コード例 #6
0
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"], "买码惹")
コード例 #7
0
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"])
コード例 #8
0
ファイル: Menu.py プロジェクト: xiaoqin00/telebot-invitecode
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")
コード例 #9
0
def Bing(message):
    '''
    Bing接口Github地址:https://github.com/xCss/bing
    '''

    bot = Bot()
    headers = {
        'Host':
        'bing.ioliu.cn',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Edg/80.0.361.66'
    }
    url = "https://bing.ioliu.cn"
    req = requests.post(url, headers=headers, verify=False)
    soup = BeautifulSoup(req.text, "lxml")
    item = soup.find_all("div", class_="item")[0]
    desc = item.find("h3").text
    date = item.find("em").text
    src = url + item.find("a", class_="ctrl download")["href"]
    if not os.path.isfile(bot.plugin_dir + "Bing/status.db"):
        with open(bot.plugin_dir + "Bing/status.db", "w") as f:
            f.write(str(time.strftime('%Y-%m-%d')))
    if not os.path.isfile(bot.plugin_dir + "Bing/today.jpg"):
        with open(bot.plugin_dir + "Bing/today.jpg", "wb") as p:
            req = requests.get(src, headers=headers)
            p.write(req.content)

    with open(bot.plugin_dir + "Bing/status.db", "r") as f:
        old = f.readline().strip()
    if date != old:
        req = requests.get(src, headers=headers)
        with open(bot.plugin_dir + "Bing/today.jpg", "wb") as p:
            p.write(req.content)
        with open(bot.plugin_dir + "Bing/status.db", "w") as f:
            f.write(str(date))

    status = bot.sendChatAction(message["chat"]["id"], "typing")
    status = bot.sendPhoto(chat_id=message["chat"]["id"],
                           photo=bot.plugin_dir + "Bing/today.jpg",
                           caption=desc + "%0A%0A" + date,
                           parse_mode="HTML",
                           reply_to_message_id=message["message_id"])
コード例 #10
0
ファイル: ID.py プロジェクト: southcat/teelebot
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")
コード例 #11
0
ファイル: Chat.py プロジェクト: southcat/teelebot
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")
コード例 #12
0
ファイル: Guard.py プロジェクト: ByWaveSite/teelebot
'''

from teelebot import Bot
from collections import defaultdict
import re
import string
import sqlite3
import time
from threading import Timer
from teelebot.handler import config
from captcha.image import ImageCaptcha
from random import randint
from io import BytesIO

config = config()
bot = Bot()


def Guard(message):
    repl = "<*>"
    DFA = DFAFilter()
    DFA.parse(bot.plugin_dir + "Guard/keywords")
    message_id = message["message_id"]
    chat_id = message["chat"]["id"]
    user_id = message["from"]["id"]
    db = SqliteDB()
    gap = 60
    bot_id = (bot.getMe()["id"])
    with open(bot.plugin_dir + "Guard/config.ini") as f:
        data_group_id = f.read().strip()
コード例 #13
0
ファイル: Firefoxmoniter.py プロジェクト: southcat/teelebot
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")
コード例 #14
0
ファイル: Hello.py プロジェクト: southcat/teelebot
def Hello(message):
    #print("你好,世界!")
    bot = Bot()
    status = bot.sendPhoto(message["chat"]["id"],
                           bot.plugin_dir + "Hello/helloworld.png")