├── beta ├── user │ ├── lottery.py │ ├── auto_download.py │ ├── start.py │ ├── reply_msg.py │ ├── del_all_msg.py │ ├── user.py │ ├── check.py │ ├── del_msg.py │ ├── follow.py │ ├── usermsg.py │ ├── bean.py │ ├── listener.py │ ├── redrain.py │ └── activityID.py ├── font │ └── jet.ttf ├── requirements.txt ├── bot │ ├── update.py │ ├── node.py │ ├── snode.py │ ├── setshort.py │ ├── cmd.py │ ├── sendfile.py │ ├── forward.py │ ├── start.py │ └── up.py ├── diy │ ├── example.py │ ├── getbotlog.py │ └── restart.py ├── ecosystem.config.js ├── set.json └── utils.py ├── backup ├── 2022-01-03 │ ├── jbot │ │ ├── user │ │ │ ├── lottery.py │ │ │ ├── auto_download.py │ │ │ ├── start.py │ │ │ ├── reply_msg.py │ │ │ ├── del_all_msg.py │ │ │ ├── del_msg.py │ │ │ ├── user.py │ │ │ ├── follow.py │ │ │ ├── usermsg.py │ │ │ ├── listener.py │ │ │ ├── utils.py │ │ │ └── redrain.py │ │ ├── font │ │ │ └── jet.ttf │ │ ├── requirements.txt │ │ ├── bot │ │ │ ├── update.py │ │ │ ├── snode.py │ │ │ ├── node.py │ │ │ ├── setshort.py │ │ │ ├── cmd.py │ │ │ ├── up.py │ │ │ ├── sendfile.py │ │ │ ├── forward.py │ │ │ └── start.py │ │ ├── diy │ │ │ ├── example.py │ │ │ ├── getbotlog.py │ │ │ ├── restart.py │ │ │ └── check_getcookie.py │ │ ├── ecosystem.config.js │ │ ├── set.json │ │ └── utils.py │ └── beta │ │ └── diy │ │ └── check_getcookie.py ├── 2021-09-06 │ ├── beta │ │ ├── aff.jpg │ │ ├── example.py │ │ ├── getbotlog.py │ │ ├── aff.py │ │ ├── restart.py │ │ ├── check_getcookie.py │ │ ├── list.py │ │ └── help.py │ └── jbot │ │ ├── example.py │ │ ├── getbotlog.py │ │ ├── restart.py │ │ ├── check_getcookie.py │ │ ├── list.py │ │ └── help.py ├── 2021-09-26 │ ├── font │ │ ├── jet.ttf │ │ └── font │ │ │ └── jet.ttf │ ├── requirements.txt │ ├── diy │ │ ├── example.py │ │ ├── diy │ │ │ ├── example.py │ │ │ ├── getbotlog.py │ │ │ ├── restart.py │ │ │ ├── check_getcookie.py │ │ │ ├── list.py │ │ │ └── help.py │ │ ├── getbotlog.py │ │ ├── restart.py │ │ ├── check_getcookie.py │ │ ├── list.py │ │ └── help.py │ ├── ecosystem.config.js │ ├── set.json │ └── utils.py ├── 2022-01-02 │ ├── jbot │ │ ├── font │ │ │ └── jet.ttf │ │ ├── user │ │ │ ├── start.py │ │ │ └── usermsg.py │ │ ├── requirements.txt │ │ ├── diy │ │ │ ├── example.py │ │ │ ├── getbotlog.py │ │ │ ├── restart.py │ │ │ ├── check_getcookie.py │ │ │ ├── list.py │ │ │ └── help.py │ │ ├── ecosystem.config.js │ │ ├── set.json │ │ └── utils.py │ ├── beta │ │ └── diy │ │ │ ├── list.py │ │ │ └── help.py │ └── shell │ │ ├── user.sh │ │ └── user_beta.sh ├── 2021-08-23 │ ├── getbotlog.py │ ├── restart.py │ ├── check_getcookie.py │ ├── list.py │ ├── help.py │ └── upbot.py ├── 2021-09-04 │ ├── getbotlog.py │ ├── restart.py │ ├── check_getcookie.py │ ├── list.py │ ├── help.py │ └── upbot.py ├── 2021-07-18 │ ├── restart.py │ ├── list.py │ ├── help.py │ └── uninstall.py ├── 2021-07-19 │ ├── restart.py │ ├── check_getcookie.py │ ├── list.py │ ├── help.py │ └── uninstall.py ├── 2021-07-21 │ ├── check_getcookie.py │ ├── list.py │ ├── restart.py │ ├── help.py │ └── uninstall.py └── 2021-07-25 │ ├── check_getcookie.py │ ├── list.py │ ├── restart.py │ ├── help.py │ └── uninstall.py ├── jbot ├── font │ └── jet.ttf ├── requirements.txt ├── diy │ ├── example.py │ ├── re.py │ ├── getbotlog.py │ ├── del.py │ ├── aff.py │ ├── restart.py │ ├── check_getcookie.py │ ├── jxjd_Global.py │ ├── list.py │ ├── id.py │ ├── bj.py │ ├── help.py │ ├── ccbean_Global.py │ └── upbot.py ├── ecosystem.config.js ├── set.json └── utils.py ├── requirements.txt ├── other └── upgrade_all_packages.py ├── shell ├── onekey.sh └── fix.sh ├── module ├── checkEnv.py ├── readCookies.py ├── replaceCookie.py ├── sendNotify │ ├── tgNofity.py │ ├── BarkNotify.py │ └── pushPlusNotify.py ├── checkCookie.py └── checkCrontab.py ├── SECURITY.md ├── pys └── sumbit.py ├── config ├── botset.json ├── diybotset.json └── bot.json ├── pagermaid └── pagermaid-jf.py └── pkc └── user └── bj_pkc.py /beta/user/lottery.py: -------------------------------------------------------------------------------- 1 | None -------------------------------------------------------------------------------- /beta/user/auto_download.py: -------------------------------------------------------------------------------- 1 | None -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/lottery.py: -------------------------------------------------------------------------------- 1 | None -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/auto_download.py: -------------------------------------------------------------------------------- 1 | None -------------------------------------------------------------------------------- /beta/font/jet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/beta/font/jet.ttf -------------------------------------------------------------------------------- /jbot/font/jet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/jbot/font/jet.ttf -------------------------------------------------------------------------------- /backup/2021-09-06/beta/aff.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/backup/2021-09-06/beta/aff.jpg -------------------------------------------------------------------------------- /backup/2021-09-26/font/jet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/backup/2021-09-26/font/jet.ttf -------------------------------------------------------------------------------- /backup/2021-09-26/font/font/jet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/backup/2021-09-26/font/font/jet.ttf -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/font/jet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/backup/2022-01-02/jbot/font/jet.ttf -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/font/jet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msechen/JD_Diy/HEAD/backup/2022-01-03/jbot/font/jet.ttf -------------------------------------------------------------------------------- /beta/user/start.py: -------------------------------------------------------------------------------- 1 | from .. import BOT_SET 2 | from .login import user 3 | if BOT_SET['开启user'].lower() == 'true': 4 | user.start() 5 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/user/start.py: -------------------------------------------------------------------------------- 1 | from .. import BOT_SET 2 | from .login import user 3 | if BOT_SET['开启user'].lower() == 'true': 4 | user.start() -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/start.py: -------------------------------------------------------------------------------- 1 | from .. import BOT_SET 2 | from .login import user 3 | if BOT_SET['开启user'].lower() == 'true': 4 | user.start() 5 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | qrcode==7.3.1 2 | Telethon==1.24.0 3 | requests==2.27.1 4 | Pillow==9.0.0 5 | python-socks==1.2.4 6 | async_timeout==4.0.2 7 | prettytable==3.0.0 -------------------------------------------------------------------------------- /beta/requirements.txt: -------------------------------------------------------------------------------- 1 | qrcode==7.3.1 2 | Telethon==1.24.0 3 | requests==2.27.1 4 | Pillow==9.0.0 5 | python-socks==1.2.4 6 | async_timeout==4.0.2 7 | prettytable==3.0.0 -------------------------------------------------------------------------------- /jbot/requirements.txt: -------------------------------------------------------------------------------- 1 | qrcode==6.1 2 | Telethon==1.21.1 3 | requests==2.25.1 4 | Pillow==8.1.2 5 | python-socks==1.2.4 6 | async_timeout==3.0.1 7 | prettytable>=2.1.0 -------------------------------------------------------------------------------- /backup/2021-09-26/requirements.txt: -------------------------------------------------------------------------------- 1 | qrcode==6.1 2 | Telethon==1.21.1 3 | requests==2.25.1 4 | Pillow==8.1.2 5 | python-socks==1.2.4 6 | async_timeout==3.0.1 7 | prettytable>=2.1.0 -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/requirements.txt: -------------------------------------------------------------------------------- 1 | qrcode==6.1 2 | Telethon==1.24.0 3 | requests==2.25.1 4 | Pillow==8.1.2 5 | python-socks==1.2.4 6 | async_timeout==3.0.1 7 | prettytable>=2.1.0 -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/requirements.txt: -------------------------------------------------------------------------------- 1 | qrcode==6.1 2 | Telethon==1.24.0 3 | requests==2.25.1 4 | Pillow==8.1.2 5 | python-socks==1.2.4 6 | async_timeout==3.0.1 7 | prettytable>=2.1.0 -------------------------------------------------------------------------------- /beta/bot/update.py: -------------------------------------------------------------------------------- 1 | version = 'version :1.0.2 beta' 2 | botlog = ''' 3 | **2022年1月3日** 4 | 整合了自走人形bot的re、id、del、da true四个功能。 5 | 对着一条消息回复re可以转发一次到当前聊天群组。 6 | 对着一条消息回复id可以查看消息发送者的个人信息。 7 | 在任意地方发送del可以删除10条消息,也可以del 3删除3条消息。 8 | 在任意地方发送dat可以删除所有你能删除的消息(管理员慎用)。 9 | ''' 10 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/update.py: -------------------------------------------------------------------------------- 1 | version = 'version :1.0.2' 2 | botlog = ''' 3 | **2022年1月3日** 4 | 整合了自走人形bot的re、id、del、da true四个功能。 5 | 对着一条消息回复re可以转发一次到当前聊天群组。 6 | 对着一条消息回复id可以查看消息发送者的个人信息。 7 | 在任意地方发送del可以删除10条消息,也可以del 3删除3条消息。 8 | 在任意地方发送dat可以删除所有你能删除的消息(管理员慎用)。 9 | ''' 10 | -------------------------------------------------------------------------------- /other/upgrade_all_packages.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import pkg_resources 3 | 4 | 5 | def main(): 6 | dists = [_ for _ in pkg_resources.working_set] 7 | for dist in dists: 8 | subprocess.call("pip install --upgrade " + dist.project_name, shell=True) 9 | 10 | 11 | if __name__ == '__main__': 12 | main() 13 | -------------------------------------------------------------------------------- /beta/diy/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /jbot/diy/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /backup/2021-09-06/beta/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /backup/2021-09-06/jbot/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /backup/2021-09-26/diy/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /backup/2021-09-26/diy/diy/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/diy/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/diy/example.py: -------------------------------------------------------------------------------- 1 | # 引入库文件,基于telethon 2 | from telethon import events 3 | # 从上级目录引入 jdbot,chat_id变量 4 | from .. import jdbot, chat_id 5 | 6 | 7 | # 格式基本固定,本例子表示从chat_id处接收到包含hello消息后,要做的事情 8 | @jdbot.on(events.NewMessage(chats=chat_id, pattern='hello')) 9 | # 定义自己的函数名称 10 | async def hi(event): 11 | # do something 12 | await jdbot.send_message(chat_id, 'hello') 13 | -------------------------------------------------------------------------------- /shell/onekey.sh: -------------------------------------------------------------------------------- 1 | if [ -d "/jd" ]; then root=/jd; else root=/ql; fi; if [ -f $root/diybot.sh ]; then rm -f $root/diybot.sh; fi; cd $root; wget https://raw.githubusercontent.com/msechen/JD_Diy/main/shell/diybot.sh; bash diybot.sh 2 | if [ -d "/jd" ]; then root=/jd; else root=/ql; fi; if [ -f $root/user.sh ]; then rm -f $root/user.sh; fi; cd $root; wget https://raw.githubusercontent.com/msechen/JD_Diy/main/shell/user.sh; bash user.sh 3 | -------------------------------------------------------------------------------- /beta/user/reply_msg.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .login import user 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^re?[ 0-9]*$', outgoing=True)) 7 | async def mycp(event): 8 | num = event.raw_text.split(' ') 9 | if isinstance(num, list) and len(num) == 2: 10 | num = int(num[-1]) 11 | else: 12 | num = 1 13 | reply = await event.get_reply_message() 14 | await event.delete() 15 | for _ in range(0, num): 16 | await reply.forward_to(int(event.chat_id)) 17 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/reply_msg.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .login import user 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^re[ 0-9]*$', outgoing=True)) 7 | async def mycp(event): 8 | num = event.raw_text.split(' ') 9 | if isinstance(num, list) and len(num) == 2: 10 | num = int(num[-1]) 11 | else: 12 | num = 1 13 | reply = await event.get_reply_message() 14 | await event.delete() 15 | for _ in range(0, num): 16 | await reply.forward_to(int(event.chat_id)) 17 | -------------------------------------------------------------------------------- /module/checkEnv.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | if __name__ == '__main__': 5 | path_list = os.path.realpath(__file__).split('/')[1:] 6 | env = '/' + '/'.join(path_list[:-2]) # 容器外路径 7 | if os.path.isfile('/ql/config/cookie.sh') or os.path.isfile(f'{env}/config/cookie.sh'): # 青龙 8 | isv4 = False 9 | if not os.path.isfile(f'{env}/config/cookie.sh'): # 青龙容器内 10 | env = '/ql' 11 | else: # v4-bot 12 | isv4 = True 13 | if not os.path.isfile(f'{env}/config/config.sh'): # v4-bot 容器内 14 | env = '/jd' 15 | print(env) 16 | -------------------------------------------------------------------------------- /beta/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [{ 3 | name: "jbot", 4 | version: "0.9.9", 5 | cwd: "..", 6 | script: "python3", 7 | args: "-m jbot", 8 | autorestart: true, 9 | watch: ["jbot"], 10 | ignore_watch: [ 11 | "jbot/*.log", 12 | "jbot/*/*.log", 13 | "jbot/__pycache__/*", 14 | "jbot/bot/__pycache__/*", 15 | "jbot/diy/__pycache__/*", 16 | "jbot/requirements.txt", 17 | "jbot/ecosystem.config.js" 18 | ], 19 | watch_delay: 1500, 20 | interpreter: "" 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /jbot/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [{ 3 | name: "jbot", 4 | version: "0.9.9", 5 | cwd: "..", 6 | script: "python", 7 | args: "-m jbot", 8 | autorestart: true, 9 | watch: ["jbot"], 10 | ignore_watch: [ 11 | "jbot/__pycache__/*", 12 | "jbot/bot/__pycache__/*", 13 | "jbot/diy/__pycache__/*", 14 | "jbot/*.log", 15 | "jbot/*/*.log", 16 | "jbot/requirements.txt", 17 | "jbot/ecosystem.config.js" 18 | ], 19 | watch_delay: 15000, 20 | interpreter: "" 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /backup/2021-09-26/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [{ 3 | name: "jbot", 4 | version: "0.9.9", 5 | cwd: "..", 6 | script: "python", 7 | args: "-m jbot", 8 | autorestart: true, 9 | watch: ["jbot"], 10 | ignore_watch: [ 11 | "jbot/__pycache__/*", 12 | "jbot/bot/__pycache__/*", 13 | "jbot/diy/__pycache__/*", 14 | "jbot/*.log", 15 | "jbot/*/*.log", 16 | "jbot/requirements.txt", 17 | "jbot/ecosystem.config.js" 18 | ], 19 | watch_delay: 15000, 20 | interpreter: "" 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [{ 3 | name: "jbot", 4 | version: "0.9.9", 5 | cwd: "..", 6 | script: "python", 7 | args: "-m jbot", 8 | autorestart: true, 9 | watch: ["jbot"], 10 | ignore_watch: [ 11 | "jbot/__pycache__/*", 12 | "jbot/bot/__pycache__/*", 13 | "jbot/diy/__pycache__/*", 14 | "jbot/*.log", 15 | "jbot/*/*.log", 16 | "jbot/requirements.txt", 17 | "jbot/ecosystem.config.js" 18 | ], 19 | watch_delay: 15000, 20 | interpreter: "" 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [{ 3 | name: "jbot", 4 | version: "0.9.9", 5 | cwd: "..", 6 | script: "python", 7 | args: "-m jbot", 8 | autorestart: true, 9 | watch: ["jbot"], 10 | ignore_watch: [ 11 | "jbot/__pycache__/*", 12 | "jbot/bot/__pycache__/*", 13 | "jbot/diy/__pycache__/*", 14 | "jbot/*.log", 15 | "jbot/*/*.log", 16 | "jbot/requirements.txt", 17 | "jbot/ecosystem.config.js" 18 | ], 19 | watch_delay: 15000, 20 | interpreter: "" 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /beta/user/del_all_msg.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .login import user 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^dat$', outgoing=True)) 7 | async def dat(context): 8 | input_chat = await context.get_input_chat() 9 | messages = [] 10 | count = 0 11 | async for message in context.client.iter_messages(input_chat, min_id=1): 12 | messages.append(message) 13 | count += 1 14 | messages.append(1) 15 | if len(messages) == 100: 16 | await context.client.delete_messages(input_chat, messages) 17 | messages = [] 18 | if messages: 19 | await context.client.delete_messages(input_chat, messages) 20 | -------------------------------------------------------------------------------- /jbot/diy/re.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import asyncio, datetime, os, re, sys, time, json, requests 6 | from unittest import result 7 | from telethon import events 8 | from urllib import parse 9 | from .user import client 10 | 11 | @client.on(events.NewMessage(pattern=r'^re[ 0-9]*$', outgoing=True)) 12 | async def mycp(event): 13 | num = event.raw_text.split(' ') 14 | if isinstance(num, list) and len(num) == 2: 15 | num = int(num[-1]) 16 | else: 17 | num = 1 18 | reply = await event.get_reply_message() 19 | await event.delete() 20 | for _ in range(0, num): 21 | await reply.forward_to(int(event.chat_id)) -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/del_all_msg.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .login import user 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^dat$', outgoing=True)) 7 | async def dat(context): 8 | input_chat = await context.get_input_chat() 9 | messages = [] 10 | count = 0 11 | async for message in context.client.iter_messages(input_chat, min_id=1): 12 | messages.append(message) 13 | count += 1 14 | messages.append(1) 15 | if len(messages) == 100: 16 | await context.client.delete_messages(input_chat, messages) 17 | messages = [] 18 | if messages: 19 | await context.client.delete_messages(input_chat, messages) 20 | -------------------------------------------------------------------------------- /jbot/set.json: -------------------------------------------------------------------------------- 1 | { 2 | "版本": "0.0.9", 3 | "每页列数": 3, 4 | "中文": "True", 5 | "开启机器人转发": "False", 6 | "机器人黑名单": "", 7 | "机器人垃圾话": "", 8 | "下载代理": "https://ghproxy.com", 9 | "启动问候": "False", 10 | "启动问候语": "叮咚,我已成功启动,欢迎使用", 11 | "开启别名": "False", 12 | "命令别名": { 13 | "bean": "表格", 14 | "chart": "豆子", 15 | "cmd": "命令", 16 | "cron": "任务", 17 | "set": "设置", 18 | "edit": "编辑", 19 | "setname": "别名", 20 | "reply": "回复", 21 | "dl": "下载", 22 | "node": "运行脚本", 23 | "snode": "执行", 24 | "getfile": "文件", 25 | "log": "日志", 26 | "setshort": "快捷设定", 27 | "a": "快捷", 28 | "b": "键盘", 29 | "addcron":"新任务", 30 | "myenv":"变量", 31 | "addenv":"加量" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /backup/2021-09-26/set.json: -------------------------------------------------------------------------------- 1 | { 2 | "版本": "0.0.9", 3 | "每页列数": 3, 4 | "中文": "True", 5 | "开启机器人转发": "False", 6 | "机器人黑名单": "", 7 | "机器人垃圾话": "", 8 | "下载代理": "https://ghproxy.com", 9 | "启动问候": "False", 10 | "启动问候语": "叮咚,我已成功启动,欢迎使用", 11 | "开启别名": "False", 12 | "命令别名": { 13 | "bean": "表格", 14 | "chart": "豆子", 15 | "cmd": "命令", 16 | "cron": "任务", 17 | "set": "设置", 18 | "edit": "编辑", 19 | "setname": "别名", 20 | "reply": "回复", 21 | "dl": "下载", 22 | "node": "运行脚本", 23 | "snode": "执行", 24 | "getfile": "文件", 25 | "log": "日志", 26 | "setshort": "快捷设定", 27 | "a": "快捷", 28 | "b": "键盘", 29 | "addcron":"新任务", 30 | "myenv":"变量", 31 | "addenv":"加量" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /beta/set.json: -------------------------------------------------------------------------------- 1 | { 2 | "版本": "1.0.2 beta", 3 | "每页列数": 3, 4 | "中文": "True", 5 | "开启机器人转发": "False", 6 | "机器人黑名单": "", 7 | "机器人垃圾话": "", 8 | "下载代理": "https://ghproxy.com", 9 | "启动问候": "False", 10 | "启动问候语": "叮咚,我已成功启动,欢迎使用", 11 | "开启别名": "False", 12 | "开启user": "False", 13 | "命令别名": { 14 | "bean": "表格", 15 | "auth": "登录", 16 | "chart": "豆子", 17 | "cmd": "命令", 18 | "cron": "任务", 19 | "set": "设置", 20 | "edit": "编辑", 21 | "setname": "别名", 22 | "reply": "回复", 23 | "dl": "下载", 24 | "node": "运行脚本", 25 | "snode": "执行", 26 | "getfile": "文件", 27 | "log": "日志", 28 | "setshort": "快捷设定", 29 | "a": "快捷", 30 | "b": "键盘", 31 | "addcron":"新任务", 32 | "myenv":"变量", 33 | "addenv":"加量" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/set.json: -------------------------------------------------------------------------------- 1 | { 2 | "版本": "0.1.1", 3 | "每页列数": 3, 4 | "中文": "True", 5 | "开启机器人转发": "False", 6 | "机器人黑名单": "", 7 | "机器人垃圾话": "", 8 | "下载代理": "https://ghproxy.com", 9 | "启动问候": "False", 10 | "启动问候语": "叮咚,我已成功启动,欢迎使用", 11 | "开启别名": "False", 12 | "开启user": "False", 13 | "命令别名": { 14 | "bean": "表格", 15 | "auth": "登录", 16 | "chart": "豆子", 17 | "cmd": "命令", 18 | "cron": "任务", 19 | "set": "设置", 20 | "edit": "编辑", 21 | "setname": "别名", 22 | "reply": "回复", 23 | "dl": "下载", 24 | "node": "运行脚本", 25 | "snode": "执行", 26 | "getfile": "文件", 27 | "log": "日志", 28 | "setshort": "快捷设定", 29 | "a": "快捷", 30 | "b": "键盘", 31 | "addcron":"新任务", 32 | "myenv":"变量", 33 | "addenv":"加量" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/set.json: -------------------------------------------------------------------------------- 1 | { 2 | "版本": "0.1.1", 3 | "每页列数": 3, 4 | "中文": "True", 5 | "开启机器人转发": "False", 6 | "机器人黑名单": "", 7 | "机器人垃圾话": "", 8 | "下载代理": "https://ghproxy.com", 9 | "启动问候": "False", 10 | "启动问候语": "叮咚,我已成功启动,欢迎使用", 11 | "开启别名": "False", 12 | "开启user": "False", 13 | "命令别名": { 14 | "bean": "表格", 15 | "auth": "登录", 16 | "chart": "豆子", 17 | "cmd": "命令", 18 | "cron": "任务", 19 | "set": "设置", 20 | "edit": "编辑", 21 | "setname": "别名", 22 | "reply": "回复", 23 | "dl": "下载", 24 | "node": "运行脚本", 25 | "snode": "执行", 26 | "getfile": "文件", 27 | "log": "日志", 28 | "setshort": "快捷设定", 29 | "a": "快捷", 30 | "b": "键盘", 31 | "addcron":"新任务", 32 | "myenv":"变量", 33 | "addenv":"加量" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /backup/2021-08-23/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from .. import chat_id, jdbot, logger, _LogDir 5 | from telethon import events 6 | import os, sys 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 10 | async def getbotlog(event): 11 | try: 12 | fpath = f"{_LogDir}/bot/run.log" 13 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 14 | except Exception as e: 15 | title = "【💥错误💥】" 16 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 17 | function = "函数名:" + sys._getframe().f_code.co_name 18 | tip = '建议百度/谷歌进行查询' 19 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 20 | logger.error(f"错误--->{str(e)}") 21 | -------------------------------------------------------------------------------- /backup/2021-09-04/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from .. import chat_id, jdbot, logger, _LogDir 5 | from telethon import events 6 | import os, sys 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 10 | async def getbotlog(event): 11 | try: 12 | fpath = f"{_LogDir}/bot/run.log" 13 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 14 | except Exception as e: 15 | title = "【💥错误💥】" 16 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 17 | function = "函数名:" + sys._getframe().f_code.co_name 18 | tip = '建议百度/谷歌进行查询' 19 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 20 | logger.error(f"错误--->{str(e)}") 21 | -------------------------------------------------------------------------------- /jbot/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import importlib 3 | import os 4 | from . import logger 5 | 6 | 7 | def load_module(module, path): 8 | files = os.listdir(path) 9 | for file in files: 10 | try: 11 | if file.endswith('.py'): 12 | filename = file.replace('.py', '') 13 | name = "jbot.{}.{}".format(module, filename) 14 | spec = importlib.util.spec_from_file_location(name, path+file) 15 | load = importlib.util.module_from_spec(spec) 16 | spec.loader.exec_module(load) 17 | sys.modules[f"jbot.{module}.{filename}"] = load 18 | logger.info(f"Bot加载-->{filename}-->完成") 19 | except Exception as e: 20 | logger.info(f"Bot加载失败-->{file}-->{str(e)}") 21 | continue 22 | 23 | -------------------------------------------------------------------------------- /beta/diy/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, LOG_DIR 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/?e$')) 13 | async def getbotlog(event): 14 | try: 15 | file = f"{LOG_DIR}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=file) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /jbot/diy/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, LOG_DIR 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{LOG_DIR}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /backup/2021-09-26/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import importlib 3 | import os 4 | from . import logger 5 | 6 | 7 | def load_module(module, path): 8 | files = os.listdir(path) 9 | for file in files: 10 | try: 11 | if file.endswith('.py'): 12 | filename = file.replace('.py', '') 13 | name = "jbot.{}.{}".format(module, filename) 14 | spec = importlib.util.spec_from_file_location(name, path+file) 15 | load = importlib.util.module_from_spec(spec) 16 | spec.loader.exec_module(load) 17 | sys.modules[f"jbot.{module}.{filename}"] = load 18 | logger.info(f"Bot加载-->{filename}-->完成") 19 | except Exception as e: 20 | logger.info(f"Bot加载失败-->{file}-->{str(e)}") 21 | continue 22 | 23 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import importlib 3 | import os 4 | from . import logger 5 | 6 | 7 | def load_module(module, path): 8 | files = os.listdir(path) 9 | for file in files: 10 | try: 11 | if file.endswith('.py'): 12 | filename = file.replace('.py', '') 13 | name = "jbot.{}.{}".format(module, filename) 14 | spec = importlib.util.spec_from_file_location(name, path+file) 15 | load = importlib.util.module_from_spec(spec) 16 | spec.loader.exec_module(load) 17 | sys.modules[f"jbot.{module}.{filename}"] = load 18 | logger.info(f"Bot加载-->{filename}-->完成") 19 | except Exception as e: 20 | logger.info(f"Bot加载失败-->{file}-->{str(e)}") 21 | continue 22 | 23 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import importlib 3 | import os 4 | from . import logger 5 | 6 | 7 | def load_module(module, path): 8 | files = os.listdir(path) 9 | for file in files: 10 | try: 11 | if file.endswith('.py'): 12 | filename = file.replace('.py', '') 13 | name = "jbot.{}.{}".format(module, filename) 14 | spec = importlib.util.spec_from_file_location(name, path+file) 15 | load = importlib.util.module_from_spec(spec) 16 | spec.loader.exec_module(load) 17 | sys.modules[f"jbot.{module}.{filename}"] = load 18 | logger.info(f"Bot加载-->{filename}-->完成") 19 | except Exception as e: 20 | logger.info(f"Bot加载失败-->{file}-->{str(e)}") 21 | continue 22 | 23 | -------------------------------------------------------------------------------- /backup/2021-09-06/beta/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, _LogDir 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{_LogDir}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /backup/2021-09-06/jbot/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, _LogDir 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{_LogDir}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /backup/2021-09-26/diy/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, LOG_DIR 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{LOG_DIR}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /backup/2021-09-26/diy/diy/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, LOG_DIR 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{LOG_DIR}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/diy/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, LOG_DIR 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{LOG_DIR}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/diy/getbotlog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from .. import chat_id, jdbot, logger, LOG_DIR 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^e$')) 13 | async def getbotlog(event): 14 | try: 15 | fpath = f"{LOG_DIR}/bot/run.log" 16 | await jdbot.send_message(chat_id, "这是bot的运行日志,用于排查问题所在", file=fpath) 17 | except Exception as e: 18 | title = "【💥错误💥】" 19 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 20 | function = "函数名:" + sys._getframe().f_code.co_name 21 | tip = '建议百度/谷歌进行查询' 22 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 23 | logger.error(f"错误--->{str(e)}") 24 | -------------------------------------------------------------------------------- /beta/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import importlib 3 | import os 4 | from . import logger 5 | 6 | 7 | def load_module(module, path): 8 | files = os.listdir(path) 9 | for file in files: 10 | try: 11 | if file.endswith('.py') or file.endswith('.pyc'): 12 | filename = file.replace('.pyc', '').replace('.py', '') 13 | name = "jbot.{}.{}".format(module, filename) 14 | spec = importlib.util.spec_from_file_location(name, path+file) 15 | load = importlib.util.module_from_spec(spec) 16 | spec.loader.exec_module(load) 17 | sys.modules[f"jbot.{module}.{filename}"] = load 18 | logger.info(f"加载成功 {filename}") 19 | except Exception as e: 20 | logger.info(f"加载失败 {file} {str(e)}") 21 | continue 22 | -------------------------------------------------------------------------------- /beta/bot/node.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, BOT_SET, ch_name 3 | from .utils import cmd, TASK_CMD 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern='/node')) 7 | async def bot_node(event): 8 | """接收/node命令后执行程序""" 9 | msg_text = event.raw_text.split(' ') 10 | if isinstance(msg_text,list) and len(msg_text) == 2: 11 | text = ''.join(msg_text[1:]) 12 | else: 13 | text = None 14 | if not text: 15 | res = '''请正确使用/node命令,如 16 | /node /abc/123.js 运行abc/123.js脚本 17 | /node /own/abc.js 运行own/abc.js脚本 18 | ''' 19 | await jdbot.send_message(chat_id, res) 20 | else: 21 | await cmd('{} {}'.format(TASK_CMD, text)) 22 | 23 | if ch_name: 24 | jdbot.add_event_handler(bot_node, events.NewMessage( 25 | from_users=chat_id, pattern=BOT_SET['命令别名']['node'])) 26 | -------------------------------------------------------------------------------- /beta/bot/snode.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, JD_DIR, BOT_SET, ch_name 3 | from .utils import cmd, snode_btn 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/snode')) 7 | async def my_snode(event): 8 | """定义supernode文件命令""" 9 | SENDER = event.sender_id 10 | path = JD_DIR 11 | page = 0 12 | filelist = None 13 | async with jdbot.conversation(SENDER, timeout=60) as conv: 14 | msg = await conv.send_message('正在查询,请稍后') 15 | while path: 16 | path, msg, page, filelist = await snode_btn(conv, SENDER, path, msg, page, filelist) 17 | if filelist and filelist.startswith('CMD-->'): 18 | await cmd(filelist.replace('CMD-->', '')) 19 | 20 | if ch_name: 21 | jdbot.add_event_handler(my_snode, events.NewMessage( 22 | from_users=chat_id, pattern=BOT_SET['命令别名']['snode'])) 23 | -------------------------------------------------------------------------------- /beta/user/user.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | from asyncio import sleep 10 | 11 | from .login import user 12 | from .. import chat_id, jdbot, logger 13 | 14 | client = user 15 | 16 | 17 | @client.on(events.NewMessage(from_users=chat_id, pattern=r"^user(\?|?)$")) 18 | async def user(event): 19 | try: 20 | await event.edit(r'`监控已正常启动!`') 21 | await sleep(5) 22 | await event.delete() 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | -------------------------------------------------------------------------------- /backup/2021-07-18/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger 11 | from ..bot.utils import V4, QL 12 | from telethon import events 13 | import os 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 17 | async def myrestart(event): 18 | try: 19 | if V4: 20 | await jdbot.send_message(chat_id, "重启程序") 21 | os.system("pm2 restart jbot") 22 | elif QL: 23 | await jdbot.send_message(chat_id, "重启程序") 24 | os.system("ql bot") 25 | except Exception as e: 26 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 27 | logger.error('something wrong,I\'m sorry\n' + str(e)) 28 | 29 | -------------------------------------------------------------------------------- /backup/2021-07-19/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger 11 | from ..bot.utils import V4, QL 12 | from telethon import events 13 | import os 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 17 | async def myrestart(event): 18 | try: 19 | if V4: 20 | await jdbot.send_message(chat_id, "重启程序") 21 | os.system("pm2 restart jbot") 22 | elif QL: 23 | await jdbot.send_message(chat_id, "重启程序") 24 | os.system("ql bot") 25 | except Exception as e: 26 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 27 | logger.error('something wrong,I\'m sorry\n' + str(e)) 28 | 29 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/snode.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, JD_DIR, BOT_SET, ch_name 3 | from .utils import cmd, snode_btn 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/snode')) 7 | async def my_snode(event): 8 | """定义supernode文件命令""" 9 | SENDER = event.sender_id 10 | path = JD_DIR 11 | page = 0 12 | filelist = None 13 | async with jdbot.conversation(SENDER, timeout=60) as conv: 14 | msg = await conv.send_message('正在查询,请稍后') 15 | while path: 16 | path, msg, page, filelist = await snode_btn(conv, SENDER, path, msg, page, filelist) 17 | if filelist and filelist.startswith('CMD-->'): 18 | await cmd(filelist.replace('CMD-->', '')) 19 | 20 | if ch_name: 21 | jdbot.add_event_handler(my_snode, events.NewMessage( 22 | from_users=chat_id, pattern=BOT_SET['命令别名']['snode'])) 23 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/node.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, BOT_SET, ch_name 3 | from .utils import cmd, TASK_CMD 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern='/node')) 7 | async def bot_node(event): 8 | """接收/node命令后执行程序""" 9 | msg_text = event.raw_text.split(' ') 10 | if isinstance(msg_text,list) and len(msg_text) == 2: 11 | text = ''.join(msg_text[1:]) 12 | else: 13 | text = None 14 | if not text: 15 | res = '''请正确使用/node命令,如 16 | /node /abc/123.js 运行abc/123.js脚本 17 | /node /own/abc.js 运行own/abc.js脚本 18 | ''' 19 | await jdbot.send_message(chat_id, res) 20 | else: 21 | await cmd('{} {}'.format(TASK_CMD, text)) 22 | 23 | if ch_name: 24 | jdbot.add_event_handler(bot_node, events.NewMessage( 25 | from_users=chat_id, pattern=BOT_SET['命令别名']['node'])) 26 | -------------------------------------------------------------------------------- /backup/2021-07-19/check_getcookie.py: -------------------------------------------------------------------------------- 1 | from .. import chat_id, jdbot, logger, TOKEN, _JdbotDir, _ConfigDir 2 | from telethon import events 3 | import os, asyncio 4 | 5 | 6 | bot_id = int(TOKEN.split(':')[0]) 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 10 | async def getcookiefile(event): 11 | try: 12 | fname = "getcookie.py" 13 | doit = True 14 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 15 | doit = False 16 | if doit: 17 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 18 | await jdbot.send_message(chat_id, msg) 19 | except Exception as e: 20 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 21 | logger.error('something wrong,I\'m sorry\n' + str(e)) 22 | -------------------------------------------------------------------------------- /beta/user/check.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from asyncio import sleep 4 | 5 | from telethon import events 6 | 7 | from .login import user 8 | from .. import jdbot, chat_id, logger 9 | 10 | 11 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r"^/check$")) 12 | async def check(event): 13 | try: 14 | if user.is_connected(): 15 | await event.reply("`user成功连接Telegram服务器!`") 16 | await sleep(5) 17 | await event.delete() 18 | else: 19 | await event.reply("`user无法连接Telegram服务器!`") 20 | except Exception as e: 21 | title = "【💥错误💥】" 22 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 23 | function = "函数名:" + sys._getframe().f_code.co_name 24 | tip = '建议百度/谷歌进行查询' 25 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 26 | logger.error(f"错误--->{str(e)}") 27 | -------------------------------------------------------------------------------- /beta/user/del_msg.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from telethon import events 4 | 5 | from .login import user 6 | 7 | 8 | @user.on(events.NewMessage(pattern=r'^del[ 0-9]*$', outgoing=True)) 9 | async def del_msg(event): 10 | try: 11 | num = event.raw_text.split(' ') 12 | if isinstance(num, list) and len(num) == 2: 13 | count = int(num[-1]) 14 | else: 15 | count = 10 16 | await event.delete() 17 | count_buffer = 0 18 | async for message in user.iter_messages(event.chat_id, from_user="me"): 19 | if count_buffer == count: 20 | break 21 | await message.delete() 22 | count_buffer += 1 23 | notification = await user.send_message(event.chat_id, f'已删除{count_buffer}/{count}') 24 | time.sleep(.5) 25 | await notification.delete() 26 | except Exception as e: 27 | await user.send_message(event.chat_id, str(e)) 28 | -------------------------------------------------------------------------------- /beta/diy/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | os.system("pm2 restart jbot") 18 | except Exception as e: 19 | title = "【💥错误💥】" 20 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 21 | function = "函数名:" + sys._getframe().f_code.co_name 22 | tip = '建议百度/谷歌进行查询' 23 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 24 | logger.error(f"错误--->{str(e)}") 25 | 26 | 27 | if ch_name: 28 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) 29 | 30 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/del_msg.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from telethon import events 4 | 5 | from .login import user 6 | 7 | 8 | @user.on(events.NewMessage(pattern=r'^del[ 0-9]*$', outgoing=True)) 9 | async def del_msg(event): 10 | try: 11 | num = event.raw_text.split(' ') 12 | if isinstance(num, list) and len(num) == 2: 13 | count = int(num[-1]) 14 | else: 15 | count = 10 16 | await event.delete() 17 | count_buffer = 0 18 | async for message in user.iter_messages(event.chat_id, from_user="me"): 19 | if count_buffer == count: 20 | break 21 | await message.delete() 22 | count_buffer += 1 23 | notification = await user.send_message(event.chat_id, f'已删除{count_buffer}/{count}') 24 | time.sleep(.5) 25 | await notification.delete() 26 | except Exception as e: 27 | await user.send_message(event.chat_id, str(e)) 28 | -------------------------------------------------------------------------------- /pys/sumbit.py: -------------------------------------------------------------------------------- 1 | from json import load 2 | from os.path import exists 3 | 4 | from telethon.sessions import StringSession 5 | from telethon.sync import TelegramClient 6 | 7 | 8 | def main(_username, _message): 9 | if exists("./session.txt"): 10 | with open("./session.txt", "r") as session: 11 | with TelegramClient(StringSession(session.read()), int(api_id), api_hash) as client: 12 | client.send_message("@" + _username, _message) 13 | else: 14 | with TelegramClient(StringSession(), int(api_id), api_hash) as client: 15 | with open("./session.txt", "w") as f: 16 | f.write(client.session.save()) 17 | 18 | 19 | if __name__ == '__main__': 20 | root = "/jd" if exists("/jd") else "/ql" 21 | with open(f"{root}/config/bot.json", "r") as f1: 22 | bot = load(f1) 23 | api_id, api_hash = bot['api_id'], bot['api_hash'] 24 | username = "" # 用户名(不带@) 25 | message = "" # 发送的消息 26 | main(username, message) 27 | -------------------------------------------------------------------------------- /config/botset.json: -------------------------------------------------------------------------------- 1 | {"\u7248\u672c": "0.1.1", "\u6bcf\u9875\u5217\u6570": 3, "\u4e2d\u6587": "True", "\u5f00\u542f\u673a\u5668\u4eba\u8f6c\u53d1": "False", "\u673a\u5668\u4eba\u9ed1\u540d\u5355": "", "\u673a\u5668\u4eba\u5783\u573e\u8bdd": "", "\u4e0b\u8f7d\u4ee3\u7406": "https://ghproxy.com", "\u542f\u52a8\u95ee\u5019": "True", "\u542f\u52a8\u95ee\u5019\u8bed": "\u53ee\u549a\uff0c\u6211\u5df2\u6210\u529f\u542f\u52a8\uff0c\u6b22\u8fce\u4f7f\u7528", "\u5f00\u542f\u522b\u540d": "False", "\u5f00\u542fuser": "False", "\u547d\u4ee4\u522b\u540d": {"bean": "\u8868\u683c", "auth": "\u767b\u5f55", "chart": "\u8c46\u5b50", "cmd": "\u547d\u4ee4", "cron": "\u4efb\u52a1", "set": "\u8bbe\u7f6e", "edit": "\u7f16\u8f91", "setname": "\u522b\u540d", "reply": "\u56de\u590d", "dl": "\u4e0b\u8f7d", "node": "\u8fd0\u884c\u811a\u672c", "snode": "\u6267\u884c", "getfile": "\u6587\u4ef6", "log": "\u65e5\u5fd7", "setshort": "\u5feb\u6377\u8bbe\u5b9a", "a": "\u5feb\u6377", "b": "\u952e\u76d8", "addcron": "\u65b0\u4efb\u52a1", "myenv": "\u53d8\u91cf", "addenv": "\u52a0\u91cf"}} -------------------------------------------------------------------------------- /backup/2021-07-21/check_getcookie.py: -------------------------------------------------------------------------------- 1 | from .. import chat_id, jdbot, logger, TOKEN, _JdbotDir, _ConfigDir, chname, mybot 2 | from telethon import events 3 | import os 4 | 5 | 6 | bot_id = int(TOKEN.split(':')[0]) 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 10 | async def getcookiefile(event): 11 | try: 12 | fname = "getcookie.py" 13 | doit = True 14 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 15 | doit = False 16 | if doit: 17 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 18 | await jdbot.send_message(chat_id, msg) 19 | except Exception as e: 20 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 21 | logger.error('something wrong,I\'m sorry\n' + str(e)) 22 | 23 | 24 | if chname: 25 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/user.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import asyncio 6 | import os 7 | import sys 8 | 9 | from telethon import events 10 | 11 | from .login import user 12 | from .. import chat_id, jdbot, logger, TOKEN 13 | from ..diy.utils import my_chat_id 14 | 15 | bot_id = int(TOKEN.split(":")[0]) 16 | 17 | 18 | client = user 19 | 20 | 21 | @client.on(events.NewMessage(chats=[bot_id, my_chat_id], from_users=chat_id, pattern=r"^user(\?|\?)$")) 22 | async def user(event): 23 | try: 24 | msg = await jdbot.send_message(chat_id, r'`user.py`监控已正常启动!') 25 | await asyncio.sleep(5) 26 | await jdbot.delete_messages(chat_id, msg) 27 | except Exception as e: 28 | title = "【💥错误💥】" 29 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 30 | function = "函数名:" + sys._getframe().f_code.co_name 31 | tip = '建议百度/谷歌进行查询' 32 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 33 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /config/diybotset.json: -------------------------------------------------------------------------------- 1 | { 2 | "↓↓↓ 你个人的测试频道 ↓↓↓": " ↓↓↓ 下面写你频道的ID ↓↓↓", 3 | "my_chat_id": "-1001728533280", 4 | "↓↓↓ 动物园自动自动开卡 ↓↓↓": "↓↓↓ False是不自动 True就是自动 ↓↓↓", 5 | "zoo_opencard": "False", 6 | "↓↓↓ 监控组队瓜分1变量频道 ↓↓↓": "↓↓↓ 都是频道的ID,按照格式写 ↓↓↓", 7 | "myzdjr_chatId": "-1001728533280", 8 | "↓↓↓ 监控组队瓜分2变量频道 ↓↓↓": "↓↓↓ 都是频道的ID,按照格式写 ↓↓↓", 9 | "myjoinTeam_chatId": "-1001728533280", 10 | "↓↓↓ 监控店铺签到变量频道 ↓↓↓": "↓↓↓ 都是频道的ID,按照格式写 ↓↓↓", 11 | "shoptokenId": "-1001728533280", 12 | "↓↓↓ 下面不用动,程序预留的 ↓↓↓": "↓↓↓ 下面不用动,程序预留的 ↓↓↓", 13 | "listenerId": "-1001728533280", 14 | "key_2": "value_2", 15 | "key_3": "value_3", 16 | "key_4": "value_4", 17 | "key_5": "value_5", 18 | "key_6": "value_6", 19 | "key_7": "value_7", 20 | "key_8": "value_8", 21 | "key_9": "value_9", 22 | "key_a": "value_a", 23 | "key_b": "value_b", 24 | "key_c": "value_c", 25 | "key_d": "value_d", 26 | "key_e": "value_e", 27 | "key_f": "value_f", 28 | "key_g": "value_g", 29 | "key_h": "value_h", 30 | "key_i": "value_i", 31 | "key_j": "value_j", 32 | "key_k": "value_k" 33 | } 34 | -------------------------------------------------------------------------------- /backup/2021-07-25/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, TOKEN, _JdbotDir, _ConfigDir, chname, mybot 6 | from telethon import events 7 | import os 8 | 9 | 10 | bot_id = int(TOKEN.split(':')[0]) 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 25 | logger.error('something wrong,I\'m sorry\n' + str(e)) 26 | 27 | 28 | if chname: 29 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /jbot/diy/del.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | import asyncio, datetime, os, re, sys, time, json, requests 4 | from unittest import result 5 | from telethon import events 6 | from urllib import parse 7 | from .user import client 8 | 9 | @client.on(events.NewMessage(pattern=r'^d[ 0-9]*$', incoming=True, outgoing=True)) 10 | async def del_msg(event): 11 | try: 12 | num = event.raw_text.split(' ') 13 | if isinstance(num, list) and len(num) == 2: 14 | count = int(num[-1]) 15 | else: 16 | count = 10 17 | await event.delete() 18 | count_buffer = 0 19 | async for message in client.iter_messages(event.chat_id, from_user="me"): 20 | if count_buffer == count: 21 | break 22 | await message.delete() 23 | count_buffer += 1 24 | notification = await client.send_message(event.chat_id, f'已删除{count_buffer}/{count}') 25 | time.sleep(.5) 26 | await notification.delete() 27 | except Exception as e: 28 | await client.send_message(event.chat_id, str(e)) -------------------------------------------------------------------------------- /module/readCookies.py: -------------------------------------------------------------------------------- 1 | import os, re 2 | 3 | 4 | 5 | def readCookies(): 6 | """ 7 | 读取 Cookie 8 | """ 9 | if isv4: 10 | config = f'{env}/config/config.sh' 11 | else: 12 | config = f'{env}/config/cookie.sh' # 青龙 13 | with open(config, 'r', encoding='utf-8') as f: 14 | config = ''.join(f.readlines()) 15 | cookie = re.findall(r"pt_key=.*;pt_pin=.*;", config) 16 | illegal_cookie = 'pt_key=xxxxxxxxxx;pt_pin=xxxx;' 17 | if illegal_cookie in cookie: 18 | m = cookie.index(illegal_cookie) 19 | del(cookie[m]) 20 | return cookie 21 | 22 | 23 | # 开始执行主程序 24 | if __name__ == '__main__': 25 | path_list = os.path.realpath(__file__).split('/')[1:] 26 | env = '/' + '/'.join(path_list[:-2]) 27 | if os.path.isfile('/ql/config/cookie.sh') or os.path.isfile(f'{env}/config/cookie.sh'): # 青龙 28 | isv4 = False 29 | if not os.path.isfile(f'{env}/config/cookie.sh'): # 青龙容器内 30 | env = '/ql' 31 | else: # v4-bot 32 | isv4 = True 33 | if not os.path.isfile(f'{env}/config/config.sh'): # v4-bot 容器内 34 | env = '/jd' 35 | readCookies() 36 | -------------------------------------------------------------------------------- /jbot/diy/aff.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, BOT_DIR, logger, ch_name, BOT_SET 6 | from telethon import events 7 | import asyncio, sys, os 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/aff$')) 11 | async def myaff(event): 12 | try: 13 | img_file = f"{BOT_DIR}/diy/aff.jpg" 14 | msg = await jdbot.send_message(chat_id, '感谢您的赞助', file=img_file) 15 | for i in range(60): 16 | msg = await jdbot.edit_message(msg, f'感谢您的赞助,消息自毁倒计时 {60 - i} 秒') 17 | await asyncio.sleep(1) 18 | await jdbot.delete_messages(chat_id, msg) 19 | except Exception as e: 20 | title = "【💥错误💥】" 21 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 22 | function = "函数名:" + sys._getframe().f_code.co_name 23 | tip = '建议百度/谷歌进行查询' 24 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 25 | logger.error(f"错误--->{str(e)}") 26 | 27 | 28 | if ch_name: 29 | jdbot.add_event_handler(myaff, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-06/beta/aff.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, _JdbotDir, logger, chname, mybot 6 | from telethon import events 7 | import asyncio, sys, os 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/aff$')) 11 | async def myaff(event): 12 | try: 13 | img_file = f"{_JdbotDir}/diy/aff.jpg" 14 | msg = await jdbot.send_message(chat_id, '感谢您的赞助', file=img_file) 15 | for i in range(60): 16 | msg = await jdbot.edit_message(msg, f'感谢您的赞助,消息自毁倒计时 {60 - i} 秒') 17 | await asyncio.sleep(1) 18 | await jdbot.delete_messages(chat_id, msg) 19 | except Exception as e: 20 | title = "【💥错误💥】" 21 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 22 | function = "函数名:" + sys._getframe().f_code.co_name 23 | tip = '建议百度/谷歌进行查询' 24 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 25 | logger.error(f"错误--->{str(e)}") 26 | 27 | 28 | if chname: 29 | jdbot.add_event_handler(myaff, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /module/replaceCookie.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def replaceCookie(): 5 | path = f'{env}/config/config.sh' 6 | with open(path, 'r', encoding='utf-8') as f1: 7 | configs = f1.readlines() 8 | for config in configs: 9 | if config.find(f'Cookie{m}=') != -1: 10 | configs[configs.index(config)] = f'Cookie{m}="{new_cookie}"\n' 11 | with open(path, 'w', encoding='utf-8') as f2: 12 | print(''.join(configs), file=f2) 13 | break 14 | elif config.find('第二区域') != -1: 15 | break 16 | 17 | 18 | if __name__ == '__main__': 19 | path_list = os.path.realpath(__file__).split('/')[1:] 20 | env = '/' + '/'.join(path_list[:-2]) # 容器外路径 21 | if os.path.isfile('/ql/config/cookie.sh') or os.path.isfile(f'{env}/config/cookie.sh'): # 青龙 22 | isv4 = False 23 | if not os.path.isfile(f'{env}/config/cookie.sh'): # 青龙容器内 24 | env = '/ql' 25 | else: # v4-bot 26 | isv4 = True 27 | if not os.path.isfile(f'{env}/config/config.sh'): # v4-bot 容器内 28 | env = '/jd' 29 | m = '1' 30 | new_cookie = 'pt_key=.*;pt_pin=.*;' 31 | replaceCookie() 32 | -------------------------------------------------------------------------------- /backup/2021-07-21/list.py: -------------------------------------------------------------------------------- 1 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 2 | from telethon import events 3 | import os 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 7 | async def mylist(event): 8 | try: 9 | lists = [] 10 | mydiy = { 11 | "checkcookie.py": "检查账号过期", 12 | "upbot.py": "升级机器人", 13 | "download.py": "下载文件", 14 | "addrepo.py": "添加仓库", 15 | "addexport.py": "添加环境变量", 16 | "editexport.py": "修改环境变量", 17 | "user.py": "user.py" 18 | } 19 | dirs = os.listdir(f"{_JdbotDir}/diy") 20 | for dir in dirs: 21 | if dir in mydiy: 22 | lists.append(mydiy[f'{dir}']) 23 | lists = '\n'.join(lists) 24 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 25 | except Exception as e: 26 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 27 | logger.error('something wrong,I\'m sorry\n' + str(e)) 28 | 29 | 30 | if chname: 31 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-07-18/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir 11 | from telethon import events 12 | import os 13 | 14 | 15 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 16 | async def mylist(event): 17 | try: 18 | lists = [] 19 | mydiy = { 20 | "checkcookie.py": "检查账号过期", 21 | "upbot.py": "升级机器人", 22 | "download.py": "下载文件", 23 | "addrepo.py": "添加仓库", 24 | "addexport.py": "添加环境变量", 25 | "editexport.py": "修改环境变量", 26 | "user.py": "user.py" 27 | } 28 | dirs = os.listdir(f"{_JdbotDir}/diy") 29 | for dir in dirs: 30 | if dir in mydiy: 31 | lists.append(mydiy[f'{dir}']) 32 | lists = '\n'.join(lists) 33 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 34 | except Exception as e: 35 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 36 | logger.error('something wrong,I\'m sorry\n' + str(e)) 37 | -------------------------------------------------------------------------------- /backup/2021-07-19/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir 11 | from telethon import events 12 | import os 13 | 14 | 15 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 16 | async def mylist(event): 17 | try: 18 | lists = [] 19 | mydiy = { 20 | "checkcookie.py": "检查账号过期", 21 | "upbot.py": "升级机器人", 22 | "download.py": "下载文件", 23 | "addrepo.py": "添加仓库", 24 | "addexport.py": "添加环境变量", 25 | "editexport.py": "修改环境变量", 26 | "user.py": "user.py" 27 | } 28 | dirs = os.listdir(f"{_JdbotDir}/diy") 29 | for dir in dirs: 30 | if dir in mydiy: 31 | lists.append(mydiy[f'{dir}']) 32 | lists = '\n'.join(lists) 33 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 34 | except Exception as e: 35 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 36 | logger.error('something wrong,I\'m sorry\n' + str(e)) 37 | -------------------------------------------------------------------------------- /pagermaid/pagermaid-jf.py: -------------------------------------------------------------------------------- 1 | #安装脚本前,修改20行bot的用户名xxxxx_bot,使用人形apt -install命令安装脚本 2 | #使用方法,基于人形命令全局回复商品链接-jf,自动返回转链结果 3 | import asyncio 4 | from pagermaid import bot 5 | from pagermaid.listener import listener 6 | from pagermaid.utils import obtain_message, alias_command 7 | 8 | @listener(is_plugin=True, outgoing=True, command=alias_command("jf"), 9 | description="京粉返利(青龙/v4 bot)", 10 | parameters="") 11 | async def stats(context): 12 | await context.edit("获取中 . . .") 13 | reply = await context.get_reply_message() 14 | try: 15 | message = await obtain_message(context) 16 | except ValueError: 17 | await context.edit("出错了呜呜呜 ~ 无效的参数。") 18 | return 19 | #下面这行bot修改成私有bot的用户名 20 | async with bot.conversation('xxxxx_bot') as conversation: 21 | await conversation.send_message('/jf ' + message) 22 | await asyncio.sleep(6) 23 | chat_response = await conversation.get_response() 24 | await bot.send_read_acknowledge(conversation.chat_id) 25 | if reply: 26 | await context.respond(chat_response, reply_to=reply) 27 | else: 28 | await context.respond(chat_response) 29 | await context.delete() 30 | -------------------------------------------------------------------------------- /backup/2021-07-25/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 6 | from telethon import events 7 | import os 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 11 | async def mylist(event): 12 | try: 13 | lists = [] 14 | mydiy = { 15 | "checkcookie.py": "检查账号过期", 16 | "upbot.py": "升级机器人", 17 | "download.py": "下载文件", 18 | "addrepo.py": "添加仓库", 19 | "addexport.py": "添加环境变量", 20 | "editexport.py": "修改环境变量", 21 | "user.py": "user.py" 22 | } 23 | dirs = os.listdir(f"{_JdbotDir}/diy") 24 | for dir in dirs: 25 | if dir in mydiy: 26 | lists.append(mydiy[f'{dir}']) 27 | lists = '\n'.join(lists) 28 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 29 | except Exception as e: 30 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 31 | logger.error('something wrong,I\'m sorry\n' + str(e)) 32 | 33 | 34 | if chname: 35 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-08-23/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, chname, mybot 6 | from telethon import events 7 | import os, sys 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 11 | async def myrestart(event): 12 | try: 13 | await jdbot.send_message(chat_id, "重启程序") 14 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 15 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 16 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 17 | os.system(cmdtext) 18 | except Exception as e: 19 | title = "【💥错误💥】" 20 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 21 | function = "函数名:" + sys._getframe().f_code.co_name 22 | tip = '建议百度/谷歌进行查询' 23 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 24 | logger.error(f"错误--->{str(e)}") 25 | 26 | 27 | if chname: 28 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) 29 | 30 | -------------------------------------------------------------------------------- /backup/2021-09-04/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, chname, mybot 6 | from telethon import events 7 | import os, sys 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 11 | async def myrestart(event): 12 | try: 13 | await jdbot.send_message(chat_id, "重启程序") 14 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 15 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 16 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 17 | os.system(cmdtext) 18 | except Exception as e: 19 | title = "【💥错误💥】" 20 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 21 | function = "函数名:" + sys._getframe().f_code.co_name 22 | tip = '建议百度/谷歌进行查询' 23 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 24 | logger.error(f"错误--->{str(e)}") 25 | 26 | 27 | if chname: 28 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) 29 | 30 | -------------------------------------------------------------------------------- /backup/2021-08-23/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, _JdbotDir, _ConfigDir, chname, mybot 6 | from telethon import events 7 | import os, sys 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 11 | async def getcookiefile(event): 12 | try: 13 | fname = "getcookie.py" 14 | doit = True 15 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 16 | doit = False 17 | if doit: 18 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 19 | await jdbot.send_message(chat_id, msg) 20 | except Exception as e: 21 | title = "【💥错误💥】" 22 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 23 | function = "函数名:" + sys._getframe().f_code.co_name 24 | tip = '建议百度/谷歌进行查询' 25 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 26 | logger.error(f"错误--->{str(e)}") 27 | 28 | 29 | if chname: 30 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /jbot/diy/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if ch_name: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /backup/2021-09-06/beta/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if chname: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /backup/2021-09-06/jbot/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if chname: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /backup/2022-01-03/beta/diy/check_getcookie.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | import os 5 | import sys 6 | 7 | from telethon import events 8 | 9 | from JD_Diy.beta import chat_id, jdbot, logger, BOT_DIR, CONFIG_DIR, ch_name, BOT_SET 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 13 | async def getcookiefile(event): 14 | try: 15 | fname = "getcookie.py" 16 | doit = True 17 | if os.path.exists(f'{BOT_DIR}/bot/{fname}') or os.path.exists(f'{BOT_DIR}/diy/{fname}'): 18 | doit = False 19 | if doit: 20 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {CONFIG_DIR} 目录中,随后执行以下命令\n/cmd mv {CONFIG_DIR}/{fname} {BOT_DIR}/diy' 21 | await jdbot.send_message(chat_id, msg) 22 | except Exception as e: 23 | title = "【💥错误💥】" 24 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 25 | function = "函数名:" + sys._getframe().f_code.co_name 26 | tip = '建议百度/谷歌进行查询' 27 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 28 | logger.error(f"错误--->{str(e)}") 29 | 30 | 31 | if ch_name: 32 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /jbot/diy/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, JD_DIR, CONFIG_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{JD_DIR}/bot/{fname}') or os.path.exists(f'{JD_DIR}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {CONFIG_DIR} 目录中,随后执行以下命令\n/cmd mv {CONFIG_DIR}/{fname} {JD_DIR}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if ch_name: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-26/diy/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if ch_name: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /config/bot.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "//开头的的都是注释,不要动,剩下的都按要求改自己的", 3 | "//user_id": "↓↓↓ 你的USERID,去除双引号 ↓↓↓", 4 | "user_id": 123456789, 5 | "//bot_token": "↓↓↓ 你的机器人TOKEN ↓↓↓", 6 | "bot_token": "123456789:ABCDEFGSHSFDASDFAD", 7 | "//api_id": "↓↓↓ https://my.telegram.org 在该网站申请到的id ↓↓↓", 8 | "api_id": "456423156", 9 | "//api_hash": "↓↓↓ https://my.telegram.org 在该网站申请到的hash ↓↓↓", 10 | "api_hash": "ASDFAWEFADSFAWEFDSFASFD", 11 | "//proxy": "↓↓↓ 使用代理改成true,不使用下方带proxy的不用动 ↓↓↓", 12 | "proxy": false, 13 | "//proxy_type": "↓↓↓ socks5 或者 http 或者 MTProxy ↓↓↓", 14 | "proxy_type": "socks5", 15 | "//proxy_add": "↓↓↓ 代理IP地址例如:192.168.99.100 ↓↓↓", 16 | "proxy_add": "192.168.99.100", 17 | "//proxy_port": "↓↓↓ 代理端口,不需要双引号例如 5890 ↓↓↓", 18 | "proxy_port": 5890, 19 | "//proxy_secret": "↓↓↓ 如果使用MTProxy,填入MTProxy代理秘钥 ↓↓↓", 20 | "proxy_secret": "", 21 | "//proxy_user": "↓↓↓ 代理的username,有就改,没有就不要动 ↓↓↓", 22 | "proxy_user": "代理的username,有则填写,无则不用动", 23 | "//proxy_password": "↓↓↓ 代理的密码,有则填写,无则不用动 ↓↓↓", 24 | "proxy_password": "代理的密码,有则填写,无则不用动", 25 | "//StartCMD": "↓↓↓ 是否开启CMD命令,开启改成true ↓↓↓", 26 | "StartCMD": false, 27 | "//noretry": "↓↓↓ 是否 关闭 bot掉线重连,默认开启,关闭改成true ↓↓↓", 28 | "noretry": false 29 | } -------------------------------------------------------------------------------- /backup/2021-09-26/diy/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, JD_DIR, CONFIG_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{JD_DIR}/bot/{fname}') or os.path.exists(f'{JD_DIR}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {CONFIG_DIR} 目录中,随后执行以下命令\n/cmd mv {CONFIG_DIR}/{fname} {JD_DIR}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if ch_name: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-26/diy/diy/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if ch_name: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/diy/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if ch_name: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/diy/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 14 | async def myrestart(event): 15 | try: 16 | await jdbot.send_message(chat_id, "重启程序") 17 | cmdtext = "if [ -d '/jd' ]; then cd /jd/jbot; pm2 start ecosystem.config.js; cd /jd; pm2 restart jbot; else " \ 18 | "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null; " \ 19 | "nohup python3 -m jbot >/ql/log/bot/bot.log 2>&1 & fi " 20 | os.system(cmdtext) 21 | except Exception as e: 22 | title = "【💥错误💥】" 23 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 24 | function = "函数名:" + sys._getframe().f_code.co_name 25 | tip = '建议百度/谷歌进行查询' 26 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 27 | logger.error(f"错误--->{str(e)}") 28 | 29 | 30 | if ch_name: 31 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) 32 | 33 | -------------------------------------------------------------------------------- /backup/2021-09-04/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir, _ConfigDir, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if chname: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-26/diy/diy/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, JD_DIR, CONFIG_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{JD_DIR}/bot/{fname}') or os.path.exists(f'{JD_DIR}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {CONFIG_DIR} 目录中,随后执行以下命令\n/cmd mv {CONFIG_DIR}/{fname} {JD_DIR}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if ch_name: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-06/beta/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir, _ConfigDir, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if chname: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-06/jbot/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir, _ConfigDir, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{_JdbotDir}/bot/{fname}') or os.path.exists(f'{_JdbotDir}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {_ConfigDir} 目录中,随后执行以下命令\n/cmd mv {_ConfigDir}/{fname} {_JdbotDir}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if chname: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/diy/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, CONFIG_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{BOT_DIR}/bot/{fname}') or os.path.exists(f'{BOT_DIR}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {CONFIG_DIR} 目录中,随后执行以下命令\n/cmd mv {CONFIG_DIR}/{fname} {BOT_DIR}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if ch_name: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/diy/check_getcookie.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, CONFIG_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getcookie$')) 14 | async def getcookiefile(event): 15 | try: 16 | fname = "getcookie.py" 17 | doit = True 18 | if os.path.exists(f'{BOT_DIR}/bot/{fname}') or os.path.exists(f'{BOT_DIR}/diy/{fname}'): 19 | doit = False 20 | if doit: 21 | msg = f'请找到一份 {fname} 文件并发送给机器人,选择存储在 {CONFIG_DIR} 目录中,随后执行以下命令\n/cmd mv {CONFIG_DIR}/{fname} {BOT_DIR}/diy' 22 | await jdbot.send_message(chat_id, msg) 23 | except Exception as e: 24 | title = "【💥错误💥】" 25 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 26 | function = "函数名:" + sys._getframe().f_code.co_name 27 | tip = '建议百度/谷歌进行查询' 28 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 29 | logger.error(f"错误--->{str(e)}") 30 | 31 | 32 | if ch_name: 33 | jdbot.add_event_handler(getcookiefile, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-07-21/restart.py: -------------------------------------------------------------------------------- 1 | from .. import chat_id, jdbot, logger, chname, mybot 2 | from ..bot.utils import V4, QL 3 | from telethon import events 4 | import os 5 | 6 | 7 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 8 | async def myrestart(event): 9 | try: 10 | if V4: 11 | await jdbot.send_message(chat_id, "重启程序") 12 | os.system("pm2 restart jbot") 13 | elif QL: 14 | await jdbot.send_message(chat_id, "重启程序") 15 | bash_file_1 = "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null" 16 | bash_file_2 = "nohup python3 -m jbot > /ql/log/bot/bot.log 2>&1 &" 17 | bash_file_3 = "rm -f restart.sh" 18 | bash_file = f"{bash_file_1}\n{bash_file_2}\n{bash_file_3}" 19 | with open('/ql/restart.sh', 'w', encoding='utf-8') as f: 20 | f.write(bash_file) 21 | os.system("bash restart.sh") 22 | except Exception as e: 23 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 24 | logger.error('something wrong,I\'m sorry\n' + str(e)) 25 | 26 | 27 | if chname: 28 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) 29 | 30 | -------------------------------------------------------------------------------- /beta/bot/setshort.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, SHORTCUT_FILE, BOT_SET, ch_name 3 | 4 | 5 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/setshort$')) 6 | async def bot_set_short(event): 7 | SENDER = event.sender_id 8 | info = '60s内回复有效\n请按格式输入您的快捷命令。例如:\n京豆通知-->jtask jd_bean_change\n更新脚本-->jup\n获取互助码-->jcode\nnode运行XX脚本-->node /XX/XX.js\nbash运行abc/123.sh脚本-->bash /abc/123.sh\n-->前边为要显示的名字,-->后边为要运行的命令\n 如添加运行脚本立即执行命令记得在后边添加now\n如不等待运行结果请添加nohup,如京豆通知-->nohup jtask jd_bean_change now\n如不添加nohup 会等待程序执行完,期间不能交互\n建议运行时间短命令不添加nohup\n部分功能青龙可能不支持,请自行测试,自行设定 ' 9 | info += '\n回复`cancel`或`取消`即可取消本次对话' 10 | async with jdbot.conversation(SENDER, timeout=180) as conv: 11 | msg = await conv.send_message(info) 12 | shortcut = await conv.get_response() 13 | if shortcut.raw_text == 'cancel' or shortcut.raw_text == '取消': 14 | await jdbot.edit_message(msg, '对话已取消') 15 | conv.cancel() 16 | return 17 | with open(SHORTCUT_FILE, 'w+', encoding='utf-8') as f: 18 | f.write(shortcut.raw_text) 19 | await conv.send_message('已设置成功可通过"/a或/b"使用') 20 | conv.cancel() 21 | 22 | if ch_name: 23 | jdbot.add_event_handler(bot_set_short, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['setshort'])) 24 | -------------------------------------------------------------------------------- /beta/user/follow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import re 7 | import sys 8 | 9 | from telethon import events 10 | 11 | from .login import user 12 | from .. import chat_id, jdbot, logger, TOKEN 13 | from ..bot.utils import V4, CONFIG_SH_FILE, get_cks, AUTH_FILE 14 | from ..diy.utils import getbean, my_chat_id 15 | 16 | bot_id = int(TOKEN.split(":")[0]) 17 | client = user 18 | 19 | 20 | @client.on(events.NewMessage(chats=[-1001320212725, -1001630980165, my_chat_id])) 21 | async def follow(event): 22 | try: 23 | url = re.findall(re.compile(r"[(](https://api\.m\.jd\.com.*?)[)]", re.S), event.message.text) 24 | if not url: 25 | return 26 | i = 0 27 | info = '关注店铺\n' 28 | for cookie in get_cks(CONFIG_SH_FILE if V4 else AUTH_FILE): 29 | i += 1 30 | info += getbean(i, cookie, url[0]) 31 | await jdbot.send_message(chat_id, info) 32 | except Exception as e: 33 | title = "【💥错误💥】" 34 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 35 | function = "函数名:" + sys._getframe().f_code.co_name 36 | tip = '建议百度/谷歌进行查询' 37 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 38 | logger.error(f"错误--->{str(e)}") 39 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/follow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import re 7 | import sys 8 | 9 | from telethon import events 10 | 11 | from .login import user 12 | from .. import chat_id, jdbot, logger, TOKEN 13 | from ..bot.utils import V4, CONFIG_SH_FILE, get_cks, AUTH_FILE 14 | from ..diy.utils import getbean, my_chat_id 15 | 16 | bot_id = int(TOKEN.split(":")[0]) 17 | client = user 18 | 19 | 20 | @client.on(events.NewMessage(chats=[-1001320212725, -1001630980165, my_chat_id])) 21 | async def follow(event): 22 | try: 23 | url = re.findall(re.compile(r"[(](https://api\.m\.jd\.com.*?)[)]", re.S), event.message.text) 24 | if not url: 25 | return 26 | i = 0 27 | info = '关注店铺\n' 28 | for cookie in get_cks(CONFIG_SH_FILE if V4 else AUTH_FILE): 29 | i += 1 30 | info += getbean(i, cookie, url[0]) 31 | await jdbot.send_message(chat_id, info) 32 | except Exception as e: 33 | title = "【💥错误💥】" 34 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 35 | function = "函数名:" + sys._getframe().f_code.co_name 36 | tip = '建议百度/谷歌进行查询' 37 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 38 | logger.error(f"错误--->{str(e)}") 39 | -------------------------------------------------------------------------------- /beta/bot/cmd.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, START_CMD, chat_id, logger, BOT_SET, ch_name 3 | from .utils import cmd 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern='/cmd')) 7 | async def my_cmd(event): 8 | """接收/cmd命令后执行程序""" 9 | logger.info(f'即将执行{event.raw_text}命令') 10 | msg_text = event.raw_text.split(' ') 11 | try: 12 | if isinstance(msg_text, list): 13 | text = ' '.join(msg_text[1:]) 14 | else: 15 | text = None 16 | if START_CMD and text: 17 | await cmd(text) 18 | logger.info(text) 19 | elif START_CMD: 20 | msg = '''请正确使用/cmd命令,如 21 | /cmd jlog # 删除旧日志 22 | /cmd jup # 更新所有脚本 23 | /cmd jcode # 导出所有互助码 24 | /cmd jcsv # 记录豆豆变化情况 25 | ''' 26 | await jdbot.send_message(chat_id, msg) 27 | else: 28 | await jdbot.send_message(chat_id, '未开启CMD命令,如需使用请修改配置文件') 29 | logger.info(f'执行{event.raw_text}命令完毕') 30 | except Exception as e: 31 | await jdbot.send_message(chat_id, f'something wrong,I\'m sorry\n{str(e)}') 32 | logger.error(f'发生了某些错误\n{str(e)}') 33 | 34 | 35 | if ch_name: 36 | jdbot.add_event_handler(my_cmd, events.NewMessage(chats=chat_id, pattern=BOT_SET['命令别名']['cmd'])) 37 | -------------------------------------------------------------------------------- /module/sendNotify/tgNofity.py: -------------------------------------------------------------------------------- 1 | import requests, os, json 2 | 3 | def tgNofity(user_id, bot_token, text): 4 | TG_API_HOST = 'api.telegram.org' 5 | url = f'https://{TG_API_HOST}/bot{bot_token}/sendMessage' 6 | body = { 7 | "chat_id": user_id, 8 | "text": text, 9 | "disable_web_page_preview": True 10 | } 11 | headers = { 12 | "ontent-Type": "application/x-www-form-urlencoded" 13 | } 14 | try: 15 | r = requests.post(url, data=body, headers=headers) 16 | if r.ok: 17 | print("Telegram发送通知消息成功🎉。\n") 18 | elif r.status_code == '400': 19 | print("请主动给bot发送一条消息并检查接收用户ID是否正确。\n") 20 | elif r.status_code == '401': 21 | print("Telegram bot token 填写错误。\n") 22 | except Exception as error: 23 | print(f"telegram发送通知消息失败!!\n{error}") 24 | 25 | 26 | # 开始执行主程序 27 | if __name__ == '__main__': 28 | path_list = os.path.realpath(__file__).split('/')[1:] 29 | env = '/' + '/'.join(path_list[:-2]) 30 | if not os.path.isfile(env + '/config/bot.json'): # 容器执行 31 | env = '/jd' 32 | bot = f'{env}/config/bot.json' 33 | with open(bot, 'r', encoding='utf-8') as botSet: 34 | bot = json.load(botSet) 35 | chat_id = bot['user_id'] 36 | bot_token = bot['bot_token'] 37 | text = 'test' 38 | tgNofity(chat_id, bot_token, text) 39 | -------------------------------------------------------------------------------- /backup/2021-07-25/restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, chname, mybot 6 | from ..bot.utils import V4, QL 7 | from telethon import events 8 | import os 9 | 10 | 11 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/restart$')) 12 | async def myrestart(event): 13 | try: 14 | if V4: 15 | await jdbot.send_message(chat_id, "重启程序") 16 | os.system("pm2 restart jbot") 17 | elif QL: 18 | await jdbot.send_message(chat_id, "重启程序") 19 | bash_file_1 = "ps -ef | grep 'python3 -m jbot' | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null" 20 | bash_file_2 = "nohup python3 -m jbot > /ql/log/bot/bot.log 2>&1 &" 21 | bash_file_3 = "rm -f restart.sh" 22 | bash_file = f"{bash_file_1}\n{bash_file_2}\n{bash_file_3}" 23 | with open('/ql/restart.sh', 'w', encoding='utf-8') as f: 24 | f.write(bash_file) 25 | os.system("bash restart.sh") 26 | except Exception as e: 27 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 28 | logger.error('something wrong,I\'m sorry\n' + str(e)) 29 | 30 | 31 | if chname: 32 | jdbot.add_event_handler(myrestart, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) 33 | 34 | -------------------------------------------------------------------------------- /jbot/diy/jxjd_Global.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .user import client 3 | 4 | from .. import jdbot 5 | from .utils import read, write 6 | import re 7 | import requests 8 | @client.on(events.NewMessage(pattern=r'^jx', outgoing=True)) 9 | async def jcmd(event): 10 | M_API_TOKEN = "951306588:373af8dc89e801376a35e603cc558a9f" 11 | headers = {"token": M_API_TOKEN} 12 | strText="" 13 | if event.is_reply is True: 14 | reply = await event.get_reply_message() 15 | strText=reply.text 16 | else: 17 | msg_text= event.raw_text.split(' ') 18 | if isinstance(msg_text, list) and len(msg_text) == 2: 19 | strText = msg_text[-1] 20 | 21 | if strText==None: 22 | await client.send_message(event.chat_id,'请指定要解析的口令,格式: jx 口令 或对口令直接回复jx ') 23 | return 24 | 25 | data = requests.post("http://ailoveu.eu.org:19840/jCommand", 26 | headers=headers, 27 | json={"code": strText}).json() 28 | code = data.get("code") 29 | if code == 200: 30 | data = data["data"] 31 | title = data["title"] 32 | jump_url = data["jumpUrl"] 33 | await client.send_message(event.chat_id,title+"\n"+jump_url) 34 | else: 35 | await client.send_message(event.chat_id,"解析出错:"+data.get("data")) 36 | 37 | -------------------------------------------------------------------------------- /module/sendNotify/BarkNotify.py: -------------------------------------------------------------------------------- 1 | import os, requests, json 2 | 3 | def BarkNotify(): 4 | url = f'https://api.day.app/{BARK_PUSH}/{title}/{content}' 5 | body = { 6 | "sound": sound 7 | } 8 | headers = { 9 | "Content-Type": "application/x-www-form-urlencoded" 10 | } 11 | try: 12 | r = requests.get(url, params=body, headers=headers, proxies={ "http": None, "https": None}) 13 | if r.ok: 14 | res = r.json() 15 | if res['code'] == 200: 16 | print(f'Bark APP发送通知消息成功🎉') 17 | else: 18 | print(res) 19 | else: 20 | print("'Bark APP发送通知调用API失败!!") 21 | except Exception as e: 22 | print(e) 23 | 24 | 25 | if __name__ == '__main__': 26 | path_list = os.path.realpath(__file__).split('/')[1:] 27 | env = '/' + '/'.join(path_list[:-2]) # 容器外路径 28 | if os.path.isfile('/ql/config/cookie.sh') or os.path.isfile(f'{env}/config/cookie.sh'): # 青龙 29 | isv4 = False 30 | if not os.path.isfile(f'{env}/config/cookie.sh'): # 青龙容器内 31 | env = '/ql' 32 | else: # v4-bot 33 | isv4 = True 34 | if not os.path.isfile(f'{env}/config/config.sh'): # v4-bot 容器内 35 | env = '/jd' 36 | BARK_PUSH = "" 37 | title = "我是一个标题!" 38 | content = "我是一个内容!" 39 | sound = "telegraph" 40 | BarkNotify() 41 | -------------------------------------------------------------------------------- /beta/user/usermsg.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .login import user 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^id$', outgoing=True)) 7 | async def check_id(event): 8 | message = await event.get_reply_message() 9 | text = f"此消息ID:`{str(event.message.id)}`\n\n" 10 | text += f"**群组信息**\nid:`{str(event.chat_id)}\n`" 11 | msg_from = event.chat if event.chat else (await event.get_chat()) 12 | if event.is_group or event.is_channel: 13 | text += f"群组名称:`{msg_from.title}`\n" 14 | try: 15 | if msg_from.username: 16 | text += f"群组用户名:`@{msg_from.username}`\n" 17 | except AttributeError: 18 | return 19 | if message: 20 | text += f"\n**查询的消息**:\n消息id:`{str(message.id)}`\n用户id:`{str(message.sender_id)}`" 21 | try: 22 | if message.sender.bot: 23 | text += f"\n机器人:`是`" 24 | if message.sender.last_name: 25 | text += f"\n姓:`{message.sender.last_name}`" 26 | try: 27 | text += f"\n名:`{message.sender.first_name}`" 28 | except TypeError: 29 | pass 30 | if message.sender.username: 31 | text += f"\n用户名:@{message.sender.username}" 32 | except AttributeError: 33 | pass 34 | await event.edit(text) 35 | else: 36 | await event.delete() 37 | -------------------------------------------------------------------------------- /module/sendNotify/pushPlusNotify.py: -------------------------------------------------------------------------------- 1 | import requests, os, json 2 | 3 | 4 | def pushPlusNotify(token, content, topic): 5 | url = 'http://www.pushplus.plus/send' 6 | if topic != '': 7 | body = { 8 | "token": token, 9 | "title": "京东脚本通知", 10 | "content": content, 11 | "template": "txt", 12 | "topic": topic, 13 | "channel": "wechat" 14 | } 15 | else: 16 | body = { 17 | "token": token, 18 | "title": "京东脚本通知", 19 | "content": content, 20 | "template": "txt", 21 | "channel": "wechat" 22 | } 23 | headers = { 24 | "Content-Type": "application/json" 25 | } 26 | try: 27 | r = requests.post(url, data=json.dumps(body), headers=headers) 28 | if r.ok and r.json()['code'] == 200: 29 | print(f'push+发送{topic}通知消息完成。') 30 | else: 31 | print(f"push+发送{topic}通知消息失败:\n{r.json()['msg']}") 32 | except Exception as e: 33 | print(e) 34 | 35 | 36 | # 开始执行主程序 37 | if __name__ == '__main__': 38 | path_list = os.path.realpath(__file__).split('/')[1:] 39 | env = '/' + '/'.join(path_list[:-2]) 40 | if not os.path.isfile(env + '/config/bot.json'): # 容器执行 41 | env = '/jd' 42 | token = '' 43 | content = '' 44 | topic = '' 45 | pushPlusNotify(token, content, topic) 46 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/usermsg.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .login import user 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^id$', outgoing=True)) 7 | async def check_id(event): 8 | message = await event.get_reply_message() 9 | text = f"此消息ID:`{str(event.message.id)}`\n\n" 10 | text += f"**群组信息**\nid:`{str(event.chat_id)}\n`" 11 | msg_from = event.chat if event.chat else (await event.get_chat()) 12 | if event.is_group or event.is_channel: 13 | text += f"群组名称:`{msg_from.title}`\n" 14 | try: 15 | if msg_from.username: 16 | text += f"群组用户名:`@{msg_from.username}`\n" 17 | except AttributeError: 18 | return 19 | if message: 20 | text += f"\n**查询的消息**:\n消息id:`{str(message.id)}`\n用户id:`{str(message.sender_id)}`" 21 | try: 22 | if message.sender.bot: 23 | text += f"\n机器人:`是`" 24 | if message.sender.last_name: 25 | text += f"\n姓:`{message.sender.last_name}`" 26 | try: 27 | text += f"\n名:`{message.sender.first_name}`" 28 | except TypeError: 29 | pass 30 | if message.sender.username: 31 | text += f"\n用户名:@{message.sender.username}" 32 | except AttributeError: 33 | pass 34 | await event.edit(text) 35 | else: 36 | await event.delete() 37 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/setshort.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, SHORTCUT_FILE, BOT_SET, ch_name 3 | 4 | 5 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/setshort$')) 6 | async def bot_set_short(event): 7 | SENDER = event.sender_id 8 | info = '60s内回复有效\n请按格式输入您的快捷命令。例如:\n京豆通知-->jtask jd_bean_change\n更新脚本-->jup\n获取互助码-->jcode\nnode运行XX脚本-->node /XX/XX.js\nbash运行abc/123.sh脚本-->bash /abc/123.sh\n-->前边为要显示的名字,-->后边为要运行的命令\n 如添加运行脚本立即执行命令记得在后边添加now\n如不等待运行结果请添加nohup,如京豆通知-->nohup jtask jd_bean_change now\n如不添加nohup 会等待程序执行完,期间不能交互\n建议运行时间短命令不添加nohup\n部分功能青龙可能不支持,请自行测试,自行设定 ' 9 | info += '\n回复`cancel`或`取消`即可取消本次对话' 10 | async with jdbot.conversation(SENDER, timeout=180) as conv: 11 | msg = await conv.send_message(info) 12 | shortcut = await conv.get_response() 13 | if shortcut.raw_text == 'cancel' or shortcut.raw_text == '取消': 14 | await jdbot.delete_messages(chat_id,msg) 15 | await jdbot.send_message(chat_id, '对话已取消') 16 | conv.cancel() 17 | return 18 | with open(SHORTCUT_FILE, 'w+', encoding='utf-8') as f: 19 | f.write(shortcut.raw_text) 20 | await conv.send_message('已设置成功可通过"/a或/b"使用') 21 | conv.cancel() 22 | 23 | if ch_name: 24 | jdbot.add_event_handler(bot_set_short, events.NewMessage( 25 | from_users=chat_id, pattern=BOT_SET['命令别名']['setshort'])) 26 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/cmd.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, START_CMD, chat_id, logger, BOT_SET, ch_name 3 | from .utils import cmd 4 | 5 | 6 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern='/cmd')) 7 | async def my_cmd(event): 8 | """接收/cmd命令后执行程序""" 9 | logger.info(f'即将执行{event.raw_text}命令') 10 | msg_text = event.raw_text.split(' ') 11 | try: 12 | if isinstance(msg_text, list): 13 | text = ' '.join(msg_text[1:]) 14 | else: 15 | text = None 16 | if START_CMD and text: 17 | await cmd(text) 18 | logger.info(text) 19 | elif START_CMD: 20 | msg = '''请正确使用/cmd命令,如 21 | /cmd jlog # 删除旧日志 22 | /cmd jup # 更新所有脚本 23 | /cmd jcode # 导出所有互助码 24 | /cmd jcsv # 记录豆豆变化情况 25 | 不建议直接使用cmd命令执行脚本,请使用/node或/snode 26 | ''' 27 | await jdbot.send_message(chat_id, msg) 28 | else: 29 | await jdbot.send_message(chat_id, '未开启CMD命令,如需使用请修改配置文件') 30 | logger.info(f'执行{event.raw_text}命令完毕') 31 | except Exception as e: 32 | await jdbot.send_message(chat_id, f'something wrong,I\'m sorry\n{str(e)}') 33 | logger.error(f'发生了某些错误\n{str(e)}') 34 | 35 | 36 | if ch_name: 37 | jdbot.add_event_handler(my_cmd, events.NewMessage( 38 | chats=chat_id, pattern=BOT_SET['命令别名']['cmd'])) 39 | -------------------------------------------------------------------------------- /backup/2021-08-23/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 6 | from telethon import events 7 | import os, sys 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 11 | async def mylist(event): 12 | try: 13 | lists = [] 14 | mydiy = { 15 | "checkcookie.py": "检查账号过期", 16 | "tempblockcookie.py": "屏蔽账号", 17 | "upbot.py": "升级机器人", 18 | "download.py": "下载文件", 19 | "addrepo.py": "添加仓库", 20 | "addexport.py": "添加环境变量", 21 | "editexport.py": "修改环境变量", 22 | "user.py": "user.py" 23 | } 24 | dirs = os.listdir(f"{_JdbotDir}/diy") 25 | for dir in dirs: 26 | if dir in mydiy: 27 | lists.append(mydiy[f'{dir}']) 28 | lists = '\n'.join(lists) 29 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 30 | except Exception as e: 31 | title = "【💥错误💥】" 32 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 33 | function = "函数名:" + sys._getframe().f_code.co_name 34 | tip = '建议百度/谷歌进行查询' 35 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 36 | logger.error(f"错误--->{str(e)}") 37 | 38 | 39 | if chname: 40 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-04/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 6 | from telethon import events 7 | import os, sys 8 | 9 | 10 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 11 | async def mylist(event): 12 | try: 13 | lists = [] 14 | mydiy = { 15 | "checkcookie.py": "检查账号过期", 16 | "tempblockcookie.py": "屏蔽账号", 17 | "upbot.py": "升级机器人", 18 | "download.py": "下载文件", 19 | "addrepo.py": "添加仓库", 20 | "addexport.py": "添加环境变量", 21 | "editexport.py": "修改环境变量", 22 | "user.py": "user.py" 23 | } 24 | dirs = os.listdir(f"{_JdbotDir}/diy") 25 | for dir in dirs: 26 | if dir in mydiy: 27 | lists.append(mydiy[f'{dir}']) 28 | lists = '\n'.join(lists) 29 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 30 | except Exception as e: 31 | title = "【💥错误💥】" 32 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 33 | function = "函数名:" + sys._getframe().f_code.co_name 34 | tip = '建议百度/谷歌进行查询' 35 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 36 | logger.error(f"错误--->{str(e)}") 37 | 38 | 39 | if chname: 40 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /jbot/diy/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{BOT_DIR}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if ch_name: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-06/beta/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{_JdbotDir}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if chname: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-06/jbot/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{_JdbotDir}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if chname: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-26/diy/diy/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{BOT_DIR}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if ch_name: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-26/diy/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{BOT_DIR}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if ch_name: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2022-01-02/beta/diy/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{BOT_DIR}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if ch_name: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/diy/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, BOT_DIR, ch_name, BOT_SET 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/list$')) 14 | async def mylist(event): 15 | try: 16 | lists = [] 17 | mydiy = { 18 | "checkcookie.py": "检查账号过期", 19 | "tempblockcookie.py": "屏蔽账号", 20 | "upbot.py": "升级机器人", 21 | "download.py": "下载文件", 22 | "addrepo.py": "添加仓库", 23 | "addexport.py": "添加环境变量", 24 | "editexport.py": "修改环境变量", 25 | "user.py": "user.py" 26 | } 27 | dirs = os.listdir(f"{BOT_DIR}/diy") 28 | for dir in dirs: 29 | if dir in mydiy: 30 | lists.append(mydiy[f'{dir}']) 31 | lists = '\n'.join(lists) 32 | await jdbot.send_message(chat_id, f"目前你拓展的功能有:\n\n{lists}") 33 | except Exception as e: 34 | title = "【💥错误💥】" 35 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 36 | function = "函数名:" + sys._getframe().f_code.co_name 37 | tip = '建议百度/谷歌进行查询' 38 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 39 | logger.error(f"错误--->{str(e)}") 40 | 41 | 42 | if ch_name: 43 | jdbot.add_event_handler(mylist, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /module/checkCookie.py: -------------------------------------------------------------------------------- 1 | import os, requests 2 | 3 | 4 | def checkCookie(): 5 | url = "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion" 6 | headers = { 7 | "Host": "me-api.jd.com", 8 | "Accept": "*/*", 9 | "Connection": "keep-alive", 10 | "Cookie": cookie, 11 | "User-Agent": "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 12 | "Accept-Language": "zh-cn", 13 | "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", 14 | "Accept-Encoding": "gzip, deflate, br" 15 | } 16 | try: 17 | r = requests.get(url, headers=headers) 18 | if r.ok: 19 | res = r.json() 20 | if res['retcode'] == '1001': 21 | expired = True 22 | return expired 23 | except Exception as e: 24 | return e 25 | 26 | 27 | if __name__ == '__main__': 28 | path_list = os.path.realpath(__file__).split('/')[1:] 29 | env = '/' + '/'.join(path_list[:-2]) # 容器外路径 30 | if os.path.isfile('/ql/config/cookie.sh') or os.path.isfile(f'{env}/config/cookie.sh'): # 青龙 31 | isv4 = False 32 | if not os.path.isfile(f'{env}/config/cookie.sh'): # 青龙容器内 33 | env = '/ql' 34 | else: # v4-bot 35 | isv4 = True 36 | if not os.path.isfile(f'{env}/config/config.sh'): # v4-bot 容器内 37 | env = '/jd' 38 | cookie = '' 39 | print(checkCookie()) 40 | -------------------------------------------------------------------------------- /pkc/user/bj_pkc.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import user,chat_id 3 | import requests 4 | 5 | #私聊狗哥https://t.me/wogouge获取token 6 | user_token='' 7 | 8 | ''' 9 | #用法 10 | 1、先去私聊狗哥号https://t.me/wogouge私发 注册 获取token,填写到上方 11 | 12 | 2、回复一个带京东链接、淘宝链接、淘宝口令的消息 比价,拉取历史比价数据 13 | 14 | 3、有任何使用问题反馈给狗哥https://t.me/wogouge 15 | ''' 16 | @user.on(events.NewMessage(pattern=r'^bj', outgoing=True)) 17 | async def bj_bot(event): 18 | msg_text = await event.get_reply_message() 19 | await event.edit('** [🐶哥](@wogouge) 比价接口** \n正在为你拉取历史比价信息......') 20 | messages=str(msg_text).split("message='")[1].split("',",1)[0] 21 | messages= messages.split("\n") 22 | SuperConvertUrl='' 23 | for message in messages: 24 | if "u.jd.com" in message or "item.jd.com" in message or "item.m.jd.com" in message or "kpl.m.jd.com" in message or '₴' in message or '₵' in message or '£' in message or '€' in message or '₤' in message or ' ' in message or '(' in message or ")" in message or "¥" in message or "$" in message or "₳" in message or "¢" in message or "m.tb.cn" in message or "?" in message: 25 | SuperConvertUrl=message 26 | header = { 27 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36', 28 | } 29 | url=f'http://api.jdauto.cf/api/SuperConvert?id={chat_id}&user_token={user_token}&key={SuperConvertUrl}' 30 | res = requests.get(url=url, headers=header).json() 31 | await event.edit(f"{res['tips']}") 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /backup/2022-01-02/shell/user.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -d "/jd" ]; then 4 | root=/jd 5 | else 6 | root=/ql 7 | fi 8 | 9 | fix() { 10 | sed -i 's/\/log/\/log$/' $root/jbot/bot/sendfile.py 11 | } 12 | 13 | install() { 14 | echo "安装user监控!" 15 | echo "" 16 | cp -f $root/repo/diybot/jbot/user/* $root/jbot/user 17 | } 18 | 19 | uninstall() { 20 | echo "卸载user监控!" 21 | echo "" 22 | rm -f $root/jbot/user/utils.py 23 | rm -f $root/jbot/user/activityID.py 24 | rm -f $root/jbot/user/follow.py 25 | rm -f $root/jbot/user/redrain.py 26 | rm -f $root/jbot/user/shoptoken.py 27 | rm -f $root/jbot/user/user.py 28 | } 29 | 30 | update() { 31 | echo "更新user监控!" 32 | echo "" 33 | raw=https://raw.githubusercontent.com/chiupam/JD_Diy/main/jbot/user 34 | wget $raw/utils.py -O $root/jbot/user/utils.py 35 | wget $raw/activityID.py -O $root/jbot/user/activityID.py 36 | wget $raw/follow.py -O $root/jbot/user/follow.py 37 | wget $raw/redrain.py -O $root/jbot/user/redrain.py 38 | wget $raw/shoptoken.py -O $root/jbot/user/shoptoken.py 39 | wget $raw/user.py -O $root/jbot/user/user.py 40 | } 41 | 42 | main() { 43 | echo "请选择您需要进行的操作:" 44 | echo " 1) 安装 user" 45 | echo " 2) 卸载 user" 46 | echo " 3) 更新 user" 47 | echo " 4) 退出脚本" 48 | echo "" 49 | echo -n "请输入编号: " 50 | read N 51 | case $N in 52 | 1) install ;; 53 | 2) uninstall ;; 54 | 3) update ;; 55 | 4) exit ;; 56 | *) echo "输入错误!请重新 bash user.sh 启动脚本" ;; 57 | esac 58 | } 59 | 60 | fix 61 | main 62 | cd $root 63 | if [ -d "/jd" ] 64 | then pm2 restart jbot 65 | else 66 | nohup python3 -m jbot > /ql/log/bot/bot.log 2>&1 & 67 | fi 68 | -------------------------------------------------------------------------------- /backup/2021-07-21/help.py: -------------------------------------------------------------------------------- 1 | from .. import chat_id, jdbot, logger, TOKEN 2 | from ..bot.utils import V4, QL 3 | from telethon import events 4 | 5 | 6 | bot_id = int(TOKEN.split(':')[0]) 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 10 | async def myhelp(event): 11 | try: 12 | msg_id = event.id 13 | if V4: 14 | msg = '''a-自定义快捷按钮 15 | bean-获取收支 16 | blockcookie-屏蔽账号 17 | chart-统计收支变化 18 | checkcookie-检测过期 19 | clearboard-删除快捷输入按钮 20 | cmd-执行cmd命令 21 | dl-下载文件 22 | edit-编辑文件 23 | export-管理环境变量 24 | help-获取帮助 25 | getcookie-扫码获取cookie 26 | getfile-获取jd目录下文件 27 | install-扩展此程序功能 28 | log-选择日志 29 | list-列出已拓展功能 30 | node-执行js脚本文件,绝对路径 31 | restart-重启本程序 32 | repo-仓库管理 33 | set-BOT设置 34 | setname-设置命令别名 35 | setshort-设置自定义按钮 36 | snode-选择脚本后台运行 37 | start-开始使用本程序 38 | uninstall-删除拓展功能 39 | up-升级原机器人 40 | upbot-更新拓展功能 41 | ver-版本''' 42 | elif QL: 43 | msg = '''a-自定义快捷按钮 44 | addenv-青龙新增环境变量 45 | bean-获取收支 46 | chart-统计收支变化 47 | clearboard-删除快捷输入按钮 48 | cmd-执行cmd命令 49 | dl-下载文件 50 | edit-编辑文件 51 | env-青龙管理环境变量 52 | export-V4管理环境变量 53 | help-获取帮助 54 | getcookie-扫码获取cookie 55 | getfile-获取jd目录下文件 56 | install-扩展此程序功能 57 | log-选择日志 58 | list-列出已拓展功能 59 | node-执行js脚本文件,绝对路径 60 | restart-重启本程序 61 | repo-仓库管理 62 | set-BOT设置 63 | setname-设置命令别名 64 | setshort-设置自定义按钮 65 | snode-选择脚本后台运行 66 | start-开始使用本程序 67 | uninstall-删除拓展功能 68 | up-升级原机器人 69 | upbot-更新拓展功能 70 | ver-版本''' 71 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 72 | except Exception as e: 73 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 74 | logger.error('something wrong,I\'m sorry\n' + str(e)) -------------------------------------------------------------------------------- /backup/2022-01-02/shell/user_beta.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -d "/jd" ]; then 4 | root=/jd 5 | else 6 | root=/ql 7 | fi 8 | 9 | fix() { 10 | sed -i 's/\/log/\/log$/' $root/jbot/bot/sendfile.py 11 | } 12 | 13 | install() { 14 | echo "安装user监控!" 15 | echo "" 16 | cp -f $root/repo/diybot/beta/user/* $root/jbot/user 17 | } 18 | 19 | uninstall() { 20 | echo "卸载user监控!" 21 | echo "" 22 | rm -f $root/jbot/user/utils.py 23 | rm -f $root/jbot/user/activityID.py 24 | rm -f $root/jbot/user/follow.py 25 | rm -f $root/jbot/user/redrain.py 26 | rm -f $root/jbot/user/shoptoken.py 27 | rm -f $root/jbot/user/user.py 28 | } 29 | 30 | update() { 31 | echo "更新user监控!" 32 | echo "" 33 | raw=https://raw.githubusercontent.com/chiupam/JD_Diy/main/beta/user 34 | wget $raw/utils.py -O $root/jbot/user/utils.py 35 | wget $raw/activityID.py -O $root/jbot/user/activityID.py 36 | wget $raw/follow.py -O $root/jbot/user/follow.py 37 | wget $raw/redrain.py -O $root/jbot/user/redrain.py 38 | wget $raw/shoptoken.py -O $root/jbot/user/shoptoken.py 39 | wget $raw/user.py -O $root/jbot/user/user.py 40 | } 41 | 42 | main() { 43 | echo "请选择您需要进行的操作:" 44 | echo " 1) 安装 user" 45 | echo " 2) 卸载 user" 46 | echo " 3) 更新 user" 47 | echo " 4) 退出脚本" 48 | echo "" 49 | echo -n "请输入编号: " 50 | read N 51 | case $N in 52 | 1) install ;; 53 | 2) uninstall ;; 54 | 3) update ;; 55 | 4) exit ;; 56 | *) echo "输入错误!请重新 bash user.sh 启动脚本" ;; 57 | esac 58 | } 59 | 60 | fix 61 | main 62 | cd $root 63 | if [ -d "/jd" ] 64 | then pm2 restart jbot 65 | else 66 | nohup python3 -m jbot > /ql/log/bot/bot.log 2>&1 & 67 | fi 68 | -------------------------------------------------------------------------------- /jbot/diy/id.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import asyncio 6 | import datetime 7 | import os 8 | import re 9 | import sys 10 | import time 11 | import json 12 | from unittest import result 13 | import requests 14 | from telethon import events 15 | from urllib import parse 16 | from .user import client 17 | 18 | #回复一个消息,查询群组,频道,消息id 19 | @client.on(events.NewMessage(pattern=r'^id$', outgoing=True)) 20 | async def check_id(event): 21 | message = await event.get_reply_message() 22 | text = f"此消息ID:`{str(event.message.id)}`\n\n" 23 | text += f"**群组信息**\nid:`{str(event.chat_id)}\n`" 24 | msg_from = event.chat if event.chat else (await event.get_chat()) 25 | if event.is_group or event.is_channel: 26 | text += f"群组名称:`{msg_from.title}`\n" 27 | try: 28 | if msg_from.username: 29 | text += f"群组用户名:`@{msg_from.username}`\n" 30 | except AttributeError: 31 | return 32 | if message: 33 | text += f"\n**查询的消息**:\n消息id:`{str(message.id)}`\n用户id:`{str(message.sender_id)}`" 34 | try: 35 | if message.sender.bot: 36 | text += f"\n机器人:`是`" 37 | if message.sender.last_name: 38 | text += f"\n姓:`{message.sender.last_name}`" 39 | try: 40 | text += f"\n名:`{message.sender.first_name}`" 41 | except TypeError: 42 | pass 43 | if message.sender.username: 44 | text += f"\n用户名:@{message.sender.username}" 45 | except AttributeError: 46 | pass 47 | await event.edit(text) 48 | else: 49 | await event.delete() -------------------------------------------------------------------------------- /backup/2021-07-25/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, TOKEN 6 | from ..bot.utils import V4, QL 7 | from telethon import events 8 | 9 | 10 | bot_id = int(TOKEN.split(':')[0]) 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 14 | async def myhelp(event): 15 | try: 16 | msg_id = event.id 17 | if V4: 18 | msg = '''a-自定义快捷按钮 19 | bean-获取收支 20 | blockcookie-屏蔽账号 21 | chart-统计收支变化 22 | checkcookie-检测过期 23 | clearboard-删除快捷输入按钮 24 | cmd-执行cmd命令 25 | dl-下载文件 26 | edit-编辑文件 27 | export-管理环境变量 28 | help-获取帮助 29 | getcookie-扫码获取cookie 30 | getfile-获取jd目录下文件 31 | install-扩展此程序功能 32 | log-选择日志 33 | list-列出已拓展功能 34 | node-执行js脚本文件,绝对路径 35 | restart-重启本程序 36 | repo-仓库管理 37 | set-BOT设置 38 | setname-设置命令别名 39 | setshort-设置自定义按钮 40 | snode-选择脚本后台运行 41 | start-开始使用本程序 42 | uninstall-删除拓展功能 43 | up-升级原机器人 44 | upbot-更新拓展功能 45 | ver-版本''' 46 | elif QL: 47 | msg = '''a-自定义快捷按钮 48 | addenv-青龙新增环境变量 49 | bean-获取收支 50 | chart-统计收支变化 51 | clearboard-删除快捷输入按钮 52 | cmd-执行cmd命令 53 | dl-下载文件 54 | edit-编辑文件 55 | env-青龙管理环境变量 56 | export-V4管理环境变量 57 | help-获取帮助 58 | getcookie-扫码获取cookie 59 | getfile-获取jd目录下文件 60 | install-扩展此程序功能 61 | log-选择日志 62 | list-列出已拓展功能 63 | node-执行js脚本文件,绝对路径 64 | restart-重启本程序 65 | repo-仓库管理 66 | set-BOT设置 67 | setname-设置命令别名 68 | setshort-设置自定义按钮 69 | snode-选择脚本后台运行 70 | start-开始使用本程序 71 | uninstall-删除拓展功能 72 | up-升级原机器人 73 | upbot-更新拓展功能 74 | ver-版本''' 75 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 76 | except Exception as e: 77 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 78 | logger.error('something wrong,I\'m sorry\n' + str(e)) -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/user/usermsg.py: -------------------------------------------------------------------------------- 1 | from .login import user 2 | from telethon import events 3 | import time 4 | 5 | 6 | @user.on(events.NewMessage(pattern=r'^re[ 0-9]*$', outgoing=True)) 7 | async def mycp(event): 8 | num = event.raw_text.split(' ') 9 | if isinstance(num, list) and len(num) == 2: 10 | num = int(num[-1]) 11 | else: 12 | num = 1 13 | reply = await event.get_reply_message() 14 | await event.delete() 15 | for _ in range(0, num): 16 | await reply.forward_to(int(event.chat_id)) 17 | 18 | 19 | @user.on(events.NewMessage(pattern=r'^id$', outgoing=True)) 20 | async def myid(event): 21 | reply = await event.get_reply_message() 22 | if reply: 23 | userid = reply.sender.id 24 | chat_id = event.chat_id 25 | await event.edit(f'当前聊天:`{chat_id}`\n你的user_id:`{userid}`') 26 | else: 27 | await event.delete() 28 | 29 | 30 | @user.on(events.NewMessage(pattern=r'^del[ 0-9]*$', outgoing=True)) 31 | async def selfprune(event): 32 | try: 33 | num = event.raw_text.split(' ') 34 | if isinstance(num, list) and len(num) == 2: 35 | count = int(num[-1]) 36 | else: 37 | count = 1 38 | await event.delete() 39 | count_buffer = 0 40 | async for message in user.iter_messages(event.chat_id, from_user="me"): 41 | if count_buffer == count: 42 | break 43 | await message.delete() 44 | count_buffer += 1 45 | notification = await user.send_message(event.chat_id, f'已删除{count_buffer}/{count}') 46 | time.sleep(.5) 47 | await notification.delete() 48 | except Exception as e: 49 | await user.send_message(event.chat_id, str(e)) 50 | -------------------------------------------------------------------------------- /backup/2021-07-18/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | from telethon import events 13 | 14 | 15 | bot_id = int(TOKEN.split(':')[0]) 16 | 17 | 18 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 19 | async def myhelp(event): 20 | try: 21 | msg_id = event.id 22 | if V4: 23 | msg = '''a-自定义快捷按钮 24 | bean-获取收支 25 | chart-统计收支变化 26 | checkcookie-检测过期 27 | clearboard-删除快捷输入按钮 28 | cmd-执行cmd命令 29 | dl-下载文件 30 | edit-编辑文件 31 | export-管理环境变量 32 | help-获取帮助 33 | getcookie-扫码获取cookie 34 | getfile-获取jd目录下文件 35 | install-扩展此程序功能 36 | log-选择日志 37 | list-列出已拓展功能 38 | node-执行js脚本文件,绝对路径 39 | restart-重启本程序 40 | repo-仓库管理 41 | set-BOT设置 42 | setname-设置命令别名 43 | setshort-设置自定义按钮 44 | snode-选择脚本后台运行 45 | start-开始使用本程序 46 | uninstall-删除拓展功能 47 | up-升级原机器人 48 | upbot-更新拓展功能 49 | ver-版本''' 50 | elif QL: 51 | msg = '''a-自定义快捷按钮 52 | addenv-青龙新增环境变量 53 | bean-获取收支 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 82 | logger.error('something wrong,I\'m sorry\n' + str(e)) -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/up.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from asyncio import exceptions 4 | 5 | import requests 6 | from telethon import events 7 | 8 | from .update import version, botlog 9 | from .. import chat_id, jdbot, logger, JD_DIR, BOT_SET 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/upbot$')) 13 | async def myupbot(event): 14 | msg = await jdbot.send_message(chat_id, "【diy正式版】\n\n准备更新程序") 15 | try: 16 | furl = "https://raw.githubusercontent.com/chiupam/JD_Diy/master/shell/bot_beta.sh" 17 | if '下载代理' in BOT_SET.keys() and str(BOT_SET['下载代理']).lower() != 'false' and 'github' in furl: 18 | furl = f'{str(BOT_SET["下载代理"])}/{furl}' 19 | resp = requests.get(furl).text 20 | if not resp: 21 | await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件失败\n请稍后重试,或尝试关闭代理重启") 22 | return 23 | cmdtext = f"bash {JD_DIR}/bot_beta.sh" 24 | fpath = f"{JD_DIR}/bot_beta.sh" 25 | with open(fpath, 'w+', encoding='utf-8') as f: 26 | f.write(resp) 27 | await jdbot.edit_message(msg, "更新过程中程序会重启,请耐心等待") 28 | os.system(cmdtext) 29 | except exceptions.TimeoutError: 30 | await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 31 | except Exception as e: 32 | title = "【💥错误💥】" 33 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 34 | function = "函数名:" + sys._getframe().f_code.co_name 35 | tip = '建议百度/谷歌进行查询' 36 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 37 | logger.error(f"错误--->{str(e)}") 38 | 39 | 40 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/ver$', incoming=True)) 41 | async def bot_ver(event): 42 | await jdbot.send_message(chat_id, f'当前版本\n{version}\n{botlog}') 43 | -------------------------------------------------------------------------------- /jbot/diy/bj.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | import requests,json,os 3 | from ..bot.utils import get_cks 4 | from .. import chat_id, jdbot, logger, API_ID, API_HASH, PROXY_START, proxy, JD_DIR, TOKEN 5 | from urllib import parse 6 | import asyncio 7 | from .user import client #用user监控的,此行改成from .login import user 8 | 9 | 10 | #私聊狗哥https://t.me/wogouge获取token 11 | user_token='' 12 | 13 | ''' 14 | #用法 15 | 1、先去私聊狗哥号https://t.me/wogouge私发 注册 获取token,填写到上方 16 | 17 | 2、回复一个带京东链接、淘宝链接、淘宝口令的消息 比价,拉取历史比价数据 18 | 19 | 3、有任何使用问题反馈给狗哥https://t.me/wogouge 20 | ''' 21 | 22 | @client.on(events.NewMessage(pattern=r'^bj', outgoing=True)) 23 | async def bj_bot(event): 24 | msg_text = await event.get_reply_message() 25 | await event.edit('** [🐶哥](@wogouge) 比价接口** \n正在为你拉取历史比价信息......') 26 | messages=str(msg_text).split("message='")[1].split("',",1)[0] 27 | messages= messages.split("\n") 28 | SuperConvertUrl='' 29 | for message in messages: 30 | if "u.jd.com" in message or "item.jd.com" in message or "item.m.jd.com" in message or "kpl.m.jd.com" in message or '₴' in message or '₵' in message or '£' in message or '€' in message or '₤' in message or ' ' in message or '(' in message or ")" in message or "¥" in message or "$" in message or "₳" in message or "¢" in message or "m.tb.cn" in message or "?" in message: 31 | SuperConvertUrl=message 32 | header = { 33 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36', 34 | } 35 | url=f'http://api.jdauto.cf/api/SuperConvert?id={chat_id}&user_token={user_token}&key={SuperConvertUrl}' 36 | res = requests.get(url=url, headers=header).json() 37 | await event.edit(f"{res['tips']}") 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /beta/user/bean.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Author: XuanPro 6 | Date: 2022/01/11 7 | """ 8 | 9 | import asyncio 10 | import os 11 | import re 12 | import traceback 13 | 14 | from telethon import events 15 | 16 | from .login import user 17 | from .. import chat_id, jdbot, logger, JD_DIR 18 | from ..user.utils import bot_id 19 | 20 | 21 | @user.on(events.NewMessage(from_users=chat_id, pattern=r"^-[bc]\s\d+$")) 22 | async def beanchange(event): 23 | """ 24 | 京豆收支变化 25 | """ 26 | try: 27 | message = event.message.text 28 | if re.search(r"\d", message): 29 | num = re.findall("\d+", message)[0] 30 | else: 31 | num = 1 32 | if "b" in message: 33 | cmdline = f"/bean {num}" 34 | jpeg = JD_DIR + '/log/bean.jpg' 35 | else: 36 | cmdline = f"/chart {num}" 37 | jpeg = JD_DIR + '/log/bot/bean.jpeg' 38 | if event.chat_id != bot_id: 39 | msg = await event.edit("正在查询,请稍后") 40 | await user.send_message(bot_id, cmdline) 41 | await asyncio.sleep(7) 42 | await msg.delete() 43 | await user.send_message(event.chat_id, f'您的账号{num}收支情况', file=jpeg) 44 | else: 45 | await event.delete() 46 | await user.send_message(bot_id, cmdline) 47 | except Exception as e: 48 | title = "【💥错误💥】" 49 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 50 | function = "函数名:" + e.__traceback__.tb_frame.f_code.co_name 51 | details = "错误详情:第 " + str(e.__traceback__.tb_lineno) + " 行" 52 | tip = '建议百度/谷歌进行查询' 53 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n{details}\n{traceback.format_exc()}\n{tip}") 54 | logger.error(f"错误--->{str(e)}") 55 | -------------------------------------------------------------------------------- /backup/2021-07-19/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | from telethon import events 13 | 14 | 15 | bot_id = int(TOKEN.split(':')[0]) 16 | 17 | 18 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 19 | async def myhelp(event): 20 | try: 21 | msg_id = event.id 22 | if V4: 23 | msg = '''a-自定义快捷按钮 24 | bean-获取收支 25 | blockcookie-屏蔽账号 26 | chart-统计收支变化 27 | checkcookie-检测过期 28 | clearboard-删除快捷输入按钮 29 | cmd-执行cmd命令 30 | dl-下载文件 31 | edit-编辑文件 32 | export-管理环境变量 33 | help-获取帮助 34 | getcookie-扫码获取cookie 35 | getfile-获取jd目录下文件 36 | install-扩展此程序功能 37 | log-选择日志 38 | list-列出已拓展功能 39 | node-执行js脚本文件,绝对路径 40 | restart-重启本程序 41 | repo-仓库管理 42 | set-BOT设置 43 | setname-设置命令别名 44 | setshort-设置自定义按钮 45 | snode-选择脚本后台运行 46 | start-开始使用本程序 47 | uninstall-删除拓展功能 48 | up-升级原机器人 49 | upbot-更新拓展功能 50 | ver-版本''' 51 | elif QL: 52 | msg = '''a-自定义快捷按钮 53 | addenv-青龙新增环境变量 54 | bean-获取收支 55 | chart-统计收支变化 56 | clearboard-删除快捷输入按钮 57 | cmd-执行cmd命令 58 | dl-下载文件 59 | edit-编辑文件 60 | env-青龙管理环境变量 61 | export-V4管理环境变量 62 | help-获取帮助 63 | getcookie-扫码获取cookie 64 | getfile-获取jd目录下文件 65 | install-扩展此程序功能 66 | log-选择日志 67 | list-列出已拓展功能 68 | node-执行js脚本文件,绝对路径 69 | restart-重启本程序 70 | repo-仓库管理 71 | set-BOT设置 72 | setname-设置命令别名 73 | setshort-设置自定义按钮 74 | snode-选择脚本后台运行 75 | start-开始使用本程序 76 | uninstall-删除拓展功能 77 | up-升级原机器人 78 | upbot-更新拓展功能 79 | ver-版本''' 80 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 81 | except Exception as e: 82 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 83 | logger.error('something wrong,I\'m sorry\n' + str(e)) -------------------------------------------------------------------------------- /beta/user/listener.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | import time 8 | 9 | from telethon import events 10 | 11 | from .login import user 12 | from .. import chat_id, jdbot, logger, TOKEN, LOG_DIR 13 | from ..diy.utils import listenerIds 14 | 15 | bot_id = int(TOKEN.split(":")[0]) 16 | client = user 17 | 18 | 19 | @client.on(events.NewMessage(chats=listenerIds, pattern=r'[^_-].*')) 20 | async def listener(event): 21 | try: 22 | user_id = event.sender_id 23 | group = event.chat.title 24 | username = str(event.sender.username if event.sender.username else "未设置") 25 | first_name = str(event.sender.first_name if event.sender.first_name else "") 26 | last_name = str(event.sender.last_name if event.sender.last_name else "") 27 | name = first_name + last_name 28 | message = "; ".join(event.message.text.split("\n")) 29 | now = time.strftime("%H:%M:%S", time.localtime()) 30 | today = time.strftime("%m-%d", time.localtime()) 31 | log = f"[{now}] 用户ID:[{user_id}] 用户名:[{username}] 昵称:[{name}] 消息:{message}\n" 32 | try: 33 | with open(f"{LOG_DIR}/listener/{group}-{today}.log", "a", encoding="utf-8") as f: 34 | f.write(log) 35 | except FileNotFoundError: 36 | os.system(f"mkdir {LOG_DIR}/listener") 37 | with open(f"{LOG_DIR}/listener/{group}-{today}.log", "a", encoding="utf-8") as f: 38 | f.write(log) 39 | except Exception as e: 40 | title = "【💥错误💥】" 41 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 42 | function = "函数名:" + sys._getframe().f_code.co_name 43 | tip = '建议百度/谷歌进行查询' 44 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 45 | logger.error(f"错误--->{str(e)}") 46 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/listener.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | import time 8 | 9 | from telethon import events 10 | 11 | from .login import user 12 | from .. import chat_id, jdbot, logger, TOKEN, LOG_DIR 13 | from ..diy.utils import listenerIds 14 | 15 | bot_id = int(TOKEN.split(":")[0]) 16 | client = user 17 | 18 | 19 | @client.on(events.NewMessage(chats=listenerIds, pattern=r'[^_-].*')) 20 | async def listener(event): 21 | try: 22 | user_id = event.sender_id 23 | group = event.chat.title 24 | username = str(event.sender.username if event.sender.username else "未设置") 25 | first_name = str(event.sender.first_name if event.sender.first_name else "") 26 | last_name = str(event.sender.last_name if event.sender.last_name else "") 27 | name = first_name + last_name 28 | message = "; ".join(event.message.text.split("\n")) 29 | now = time.strftime("%H:%M:%S", time.localtime()) 30 | today = time.strftime("%m-%d", time.localtime()) 31 | log = f"[{now}] 用户ID:[{user_id}] 用户名:[{username}] 昵称:[{name}] 消息:{message}\n" 32 | try: 33 | with open(f"{LOG_DIR}/listener/{group}-{today}.log", "a", encoding="utf-8") as f: 34 | f.write(log) 35 | except FileNotFoundError: 36 | os.system(f"mkdir {LOG_DIR}/listener") 37 | with open(f"{LOG_DIR}/listener/{group}-{today}.log", "a", encoding="utf-8") as f: 38 | f.write(log) 39 | except Exception as e: 40 | title = "【💥错误💥】" 41 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 42 | function = "函数名:" + sys._getframe().f_code.co_name 43 | tip = '建议百度/谷歌进行查询' 44 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 45 | logger.error(f"错误--->{str(e)}") 46 | -------------------------------------------------------------------------------- /beta/bot/sendfile.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from telethon import events 4 | 5 | from .utils import log_btn 6 | from .. import jdbot, chat_id, LOG_DIR, JD_DIR, BOT_SET, ch_name 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/log$')) 10 | async def bot_log(event): 11 | """定义日志文件操作""" 12 | SENDER = event.sender_id 13 | path = LOG_DIR 14 | page = 0 15 | filelist = None 16 | async with jdbot.conversation(SENDER, timeout=60) as conv: 17 | msg = await conv.send_message('正在查询,请稍后') 18 | while path: 19 | path, msg, page, filelist = await log_btn(conv, SENDER, path, msg, page, filelist) 20 | 21 | 22 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getfile')) 23 | async def bot_getfile(event): 24 | """定义获取文件命令""" 25 | SENDER = event.sender_id 26 | path = JD_DIR 27 | page = 0 28 | msg_text = event.raw_text.split(' ') 29 | if len(msg_text) == 2: 30 | text = msg_text[-1] 31 | else: 32 | text = None 33 | if text and os.path.isfile(text): 34 | await jdbot.send_message(chat_id, '请查收文件', file=text) 35 | return 36 | elif text and os.path.isdir(text): 37 | path = text 38 | filelist = None 39 | elif text: 40 | await jdbot.send_message(chat_id, 'please marksure it\'s a dir or a file') 41 | filelist = None 42 | else: 43 | filelist = None 44 | async with jdbot.conversation(SENDER, timeout=60) as conv: 45 | msg = await conv.send_message('正在查询,请稍后') 46 | while path: 47 | path, msg, page, filelist = await log_btn(conv, SENDER, path, msg, page, filelist) 48 | 49 | 50 | if ch_name: 51 | jdbot.add_event_handler(bot_getfile, events.NewMessage( 52 | from_users=chat_id, pattern=BOT_SET['命令别名']['getfile'])) 53 | jdbot.add_event_handler(bot_log, events.NewMessage( 54 | from_users=chat_id, pattern=BOT_SET['命令别名']['log'])) 55 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/sendfile.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from telethon import events 4 | 5 | from .utils import log_btn 6 | from .. import jdbot, chat_id, LOG_DIR, JD_DIR, BOT_SET, ch_name 7 | 8 | 9 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/log$')) 10 | async def bot_log(event): 11 | """定义日志文件操作""" 12 | SENDER = event.sender_id 13 | path = LOG_DIR 14 | page = 0 15 | filelist = None 16 | async with jdbot.conversation(SENDER, timeout=60) as conv: 17 | msg = await conv.send_message('正在查询,请稍后') 18 | while path: 19 | path, msg, page, filelist = await log_btn(conv, SENDER, path, msg, page, filelist) 20 | 21 | 22 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/getfile')) 23 | async def bot_getfile(event): 24 | """定义获取文件命令""" 25 | SENDER = event.sender_id 26 | path = JD_DIR 27 | page = 0 28 | msg_text = event.raw_text.split(' ') 29 | if len(msg_text) == 2: 30 | text = msg_text[-1] 31 | else: 32 | text = None 33 | if text and os.path.isfile(text): 34 | await jdbot.send_message(chat_id, '请查收文件', file=text) 35 | return 36 | elif text and os.path.isdir(text): 37 | path = text 38 | filelist = None 39 | elif text: 40 | await jdbot.send_message(chat_id, 'please marksure it\'s a dir or a file') 41 | filelist = None 42 | else: 43 | filelist = None 44 | async with jdbot.conversation(SENDER, timeout=60) as conv: 45 | msg = await conv.send_message('正在查询,请稍后') 46 | while path: 47 | path, msg, page, filelist = await log_btn(conv, SENDER, path, msg, page, filelist) 48 | 49 | 50 | if ch_name: 51 | jdbot.add_event_handler(bot_getfile, events.NewMessage( 52 | from_users=chat_id, pattern=BOT_SET['命令别名']['getfile'])) 53 | jdbot.add_event_handler(bot_log, events.NewMessage( 54 | from_users=chat_id, pattern=BOT_SET['命令别名']['log'])) 55 | -------------------------------------------------------------------------------- /backup/2021-08-23/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, TOKEN 6 | from ..bot.utils import V4, QL 7 | from telethon import events 8 | import sys, os 9 | 10 | 11 | bot_id = int(TOKEN.split(':')[0]) 12 | 13 | 14 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 15 | async def myhelp(event): 16 | try: 17 | msg_id = event.id 18 | if V4: 19 | msg = '''a-自定义快捷按钮 20 | bean-获取收支 21 | blockcookie-屏蔽账号 22 | chart-统计收支变化 23 | checkcookie-检测过期 24 | clearboard-删除快捷输入按钮 25 | cmd-执行cmd命令 26 | dl-下载文件 27 | edit-编辑文件 28 | export-管理环境变量 29 | help-获取帮助 30 | getcookie-扫码获取cookie 31 | getfile-获取jd目录下文件 32 | install-扩展此程序功能 33 | log-选择日志 34 | list-列出已拓展功能 35 | node-执行js脚本文件,绝对路径 36 | restart-重启本程序 37 | repo-仓库管理 38 | set-BOT设置 39 | setname-设置命令别名 40 | setshort-设置自定义按钮 41 | snode-选择脚本后台运行 42 | start-开始使用本程序 43 | uninstall-删除拓展功能 44 | up-升级原机器人 45 | upbot-更新拓展功能 46 | ver-版本''' 47 | elif QL: 48 | msg = '''a-自定义快捷按钮 49 | addenv-青龙新增环境变量 50 | bean-获取收支 51 | blockcookie-屏蔽账号 52 | chart-统计收支变化 53 | clearboard-删除快捷输入按钮 54 | cmd-执行cmd命令 55 | dl-下载文件 56 | edit-编辑文件 57 | env-青龙管理环境变量 58 | export-V4管理环境变量 59 | help-获取帮助 60 | getcookie-扫码获取cookie 61 | getfile-获取jd目录下文件 62 | install-扩展此程序功能 63 | log-选择日志 64 | list-列出已拓展功能 65 | node-执行js脚本文件,绝对路径 66 | restart-重启本程序 67 | repo-仓库管理 68 | set-BOT设置 69 | setname-设置命令别名 70 | setshort-设置自定义按钮 71 | snode-选择脚本后台运行 72 | start-开始使用本程序 73 | uninstall-删除拓展功能 74 | up-升级原机器人 75 | upbot-更新拓展功能 76 | ver-版本''' 77 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 78 | except Exception as e: 79 | title = "【💥错误💥】" 80 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 81 | function = "函数名:" + sys._getframe().f_code.co_name 82 | tip = '建议百度/谷歌进行查询' 83 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 84 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /jbot/diy/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /backup/2021-09-04/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /backup/2021-09-26/diy/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /backup/2021-09-06/beta/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /backup/2021-09-06/jbot/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /backup/2021-09-26/diy/diy/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /backup/2022-01-02/jbot/diy/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from .. import chat_id, jdbot, logger, TOKEN 11 | from ..bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /module/checkCrontab.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def findCrontab(): 5 | crontab_list = f'{env}/config/crontab.list' 6 | with open(crontab_list, 'r', encoding='utf-8') as f1: 7 | crontabs = f1.readlines() 8 | for crontab in crontabs: 9 | if crontab.find("jd_dreamFactory.js") != -1: 10 | cron = crontab.split(" ")[:5] 11 | cron = ' '.join(cron) 12 | return cron 13 | return False 14 | 15 | 16 | def checkCrontab(): 17 | """ 18 | 新旧命令对比,有新命令则写入新命令 19 | """ 20 | storage = '/' + path_list[-2] 21 | file = '/' + path_list[-1] 22 | crontab_list = f'{env}/config/crontab.list' 23 | key = '# 获取京喜工厂团ID(请勿删除此行)\n' 24 | new = f'{cron} python /jd{storage}{file} >> /jd/log{file.split(".")[0]}.log 2>&1\n' 25 | with open(crontab_list, 'r', encoding='utf-8') as f1: 26 | crontab = f1.readlines() 27 | if crontab[-1] == '\n': 28 | del(crontab[-1]) 29 | if key in crontab: 30 | m = crontab.index(key) + 1 31 | if crontab[m] != new: 32 | crontab[m] = new 33 | with open(crontab_list, 'w', encoding='utf-8') as f2: 34 | print(''.join(crontab), file=f2) 35 | else: 36 | crontab.append(f'\n{key}{new}') 37 | with open(crontab_list, 'w', encoding='utf-8') as f2: 38 | print(''.join(crontab), file=f2) 39 | 40 | 41 | 42 | # 开始执行主程序 43 | if __name__ == '__main__': 44 | path_list = os.path.realpath(__file__).split('/')[1:] 45 | env = '/' + '/'.join(path_list[:-2]) 46 | if os.path.isfile('/ql/config/cookie.sh') or os.path.isfile(f'{env}/config/cookie.sh'): # 青龙 47 | isv4 = False 48 | if not os.path.isfile(f'{env}/config/cookie.sh'): # 青龙容器内 49 | env = '/ql' 50 | else: # v4-bot 51 | isv4 = True 52 | if not os.path.isfile(f'{env}/config/config.sh'): # v4-bot 容器内 53 | env = '/jd' 54 | cron = findCrontab() 55 | if not cron: 56 | cron = "" 57 | checkCrontab() 58 | -------------------------------------------------------------------------------- /backup/2022-01-02/beta/diy/help.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import sys 7 | 8 | from telethon import events 9 | 10 | from JD_Diy.beta import chat_id, jdbot, logger, TOKEN 11 | from JD_Diy.beta.bot.utils import V4, QL 12 | 13 | bot_id = int(TOKEN.split(':')[0]) 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/help$')) 17 | async def myhelp(event): 18 | try: 19 | msg_id = event.id 20 | if V4: 21 | msg = '''a-自定义快捷按钮 22 | bean-获取收支 23 | blockcookie-屏蔽账号 24 | chart-统计收支变化 25 | checkcookie-检测过期 26 | clearboard-删除快捷输入按钮 27 | cmd-执行cmd命令 28 | dl-下载文件 29 | edit-编辑文件 30 | export-管理环境变量 31 | help-获取帮助 32 | getcookie-扫码获取cookie 33 | getfile-获取jd目录下文件 34 | install-扩展此程序功能 35 | log-选择日志 36 | list-列出已拓展功能 37 | node-执行js脚本文件,绝对路径 38 | restart-重启本程序 39 | repo-仓库管理 40 | set-BOT设置 41 | setname-设置命令别名 42 | setshort-设置自定义按钮 43 | snode-选择脚本后台运行 44 | start-开始使用本程序 45 | uninstall-删除拓展功能 46 | up-升级原机器人 47 | upbot-更新拓展功能 48 | ver-版本''' 49 | elif QL: 50 | msg = '''a-自定义快捷按钮 51 | addenv-青龙新增环境变量 52 | bean-获取收支 53 | blockcookie-屏蔽账号 54 | chart-统计收支变化 55 | clearboard-删除快捷输入按钮 56 | cmd-执行cmd命令 57 | dl-下载文件 58 | edit-编辑文件 59 | env-青龙管理环境变量 60 | export-V4管理环境变量 61 | help-获取帮助 62 | getcookie-扫码获取cookie 63 | getfile-获取jd目录下文件 64 | install-扩展此程序功能 65 | log-选择日志 66 | list-列出已拓展功能 67 | node-执行js脚本文件,绝对路径 68 | restart-重启本程序 69 | repo-仓库管理 70 | set-BOT设置 71 | setname-设置命令别名 72 | setshort-设置自定义按钮 73 | snode-选择脚本后台运行 74 | start-开始使用本程序 75 | uninstall-删除拓展功能 76 | up-升级原机器人 77 | upbot-更新拓展功能 78 | ver-版本''' 79 | await jdbot.edit_message(bot_id, msg_id + 1, msg) 80 | except Exception as e: 81 | title = "【💥错误💥】" 82 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 83 | function = "函数名:" + sys._getframe().f_code.co_name 84 | tip = '建议百度/谷歌进行查询' 85 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 86 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /jbot/diy/ccbean_Global.py: -------------------------------------------------------------------------------- 1 | from telethon import events, Button 2 | from .user import client 3 | 4 | from .. import jdbot 5 | from ..bot.utils import cmd, TASK_CMD,split_list, press_event 6 | from ..diy.utils import read, write 7 | import asyncio 8 | import re 9 | @client.on(events.NewMessage(pattern=r'^cb', outgoing=True)) 10 | async def CCBeanInfo(event): 11 | msg_text= event.raw_text.split(' ') 12 | if isinstance(msg_text, list) and len(msg_text) == 2: 13 | text = msg_text[-1] 14 | else: 15 | text = None 16 | 17 | if text==None: 18 | await event.edit('请指定要查询的账号,格式: cb 1 或 cb ptpin') 19 | return 20 | 21 | key="BOTCHECKCODE" 22 | kv=f'{key}="{text}"' 23 | change="" 24 | configs = read("str") 25 | if kv not in configs: 26 | if key in configs: 27 | configs = re.sub(f'{key}=("|\').*("|\')', kv, configs) 28 | change += f"【替换】环境变量:`{kv}`\n" 29 | write(configs) 30 | else: 31 | configs = read("str") 32 | configs += f'export {key}="{text}"\n' 33 | change += f"【新增】环境变量:`{kv}`\n" 34 | write(configs) 35 | 36 | 37 | await event.edit('开始查询账号'+text+'的资产,请稍后...') 38 | 39 | cmdtext="jtask /jd/scripts/bot_jd_bean_change.js now" 40 | p = await asyncio.create_subprocess_shell( 41 | cmdtext, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) 42 | res_bytes, res_err = await p.communicate() 43 | res = res_bytes.decode('utf-8') 44 | txt=res.split('\n') 45 | strReturn="" 46 | if res: 47 | for line in txt: 48 | if "】" in line or "明细" in line: 49 | strReturn=strReturn+line+'\n' 50 | 51 | if strReturn: 52 | await event.delete() 53 | await client.send_message(event.chat_id, strReturn) 54 | else: 55 | await event.delete() 56 | await client.send_message(event.chat_id,'查询失败!') -------------------------------------------------------------------------------- /backup/2021-07-21/uninstall.py: -------------------------------------------------------------------------------- 1 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 2 | from ..bot.utils import split_list, row, press_event, V4, QL 3 | from telethon import events, Button 4 | from asyncio import exceptions 5 | import os 6 | 7 | 8 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/uninstall$')) 9 | async def myuninstall(event): 10 | try: 11 | SENDER = event.sender_id 12 | mydiy = { 13 | "checkcookie.py": "检查账号过期", 14 | "upbot.py": "升级机器人", 15 | "download.py": "下载文件", 16 | "addrepo.py": "添加仓库", 17 | "addexport.py": "添加环境变量", 18 | "editexport.py": "修改环境变量", 19 | "user.py": "user.py" 20 | } 21 | btns = [] 22 | dirs = os.listdir(f"{_JdbotDir}/diy") 23 | for dir in dirs: 24 | if dir in mydiy: 25 | btns.append(Button.inline(mydiy[f'{dir}'], data=dir)) 26 | btns.append(Button.inline("帮我取消对话", data='cancel')) 27 | async with jdbot.conversation(SENDER, timeout=60) as conv: 28 | msg = await conv.send_message("请问你需要删除哪个功能?", buttons=split_list(btns, row)) 29 | convdata = await conv.wait_event(press_event(SENDER)) 30 | fname = bytes.decode(convdata.data) 31 | if fname == 'cancel': 32 | await jdbot.edit_message(msg, '对话已取消,感谢你的使用') 33 | conv.cancel() 34 | return 35 | conv.cancel() 36 | fpath = f"{_JdbotDir}/diy/{fname}" 37 | os.system(f'rm -rf {fpath}') 38 | if not os.path.isfile(fpath): 39 | await jdbot.edit_message(msg, "删除成功,正在自动重启") 40 | else: 41 | await jdbot.edit_message(msg, f"删除失败,请手动删除{fpath}文件") 42 | except exceptions.TimeoutError: 43 | msg = await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 44 | except Exception as e: 45 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 46 | logger.error('something wrong,I\'m sorry\n' + str(e)) 47 | 48 | 49 | if chname: 50 | jdbot.add_event_handler(myuninstall, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /beta/bot/forward.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, BOT_SET, ch_name 3 | import random 4 | 5 | 6 | @jdbot.on(events.NewMessage()) 7 | async def my_forward(event): 8 | try: 9 | if BOT_SET['开启机器人转发'].lower() != 'false' and event.chat_id != chat_id and str(event.chat_id) not in BOT_SET[ 10 | '机器人黑名单']: 11 | await jdbot.send_message(chat_id, f'您的机器人接收到消息。来自:```{event.chat_id}```') 12 | await jdbot.forward_messages(chat_id, event.id, event.chat_id) 13 | elif BOT_SET['开启机器人转发'].lower() != 'false' and str(event.chat_id) in BOT_SET['机器人黑名单']: 14 | words = BOT_SET['机器人垃圾话'].split('|') 15 | word = words[random.randint(0, len(words) - 1)] 16 | await jdbot.send_message(event.chat_id, str(word)) 17 | except Exception as e: 18 | await jdbot.send_message(chat_id, str(e)) 19 | 20 | 21 | @jdbot.on(events.NewMessage(chats=chat_id, pattern=r'^/reply')) 22 | async def my_reply(event): 23 | try: 24 | msg_text = event.raw_text.split(' ') 25 | if isinstance(msg_text, list) and len(msg_text) == 3: 26 | text = msg_text[1:] 27 | else: 28 | text = None 29 | if not text: 30 | info = '使用方法:/reply 123455676 你想说的话' 31 | await jdbot.send_message(chat_id, info) 32 | else: 33 | await jdbot.send_message(int(text[0]), text[1]) 34 | except Exception as e: 35 | await jdbot.send_message(chat_id, str(e)) 36 | 37 | 38 | if ch_name: 39 | jdbot.add_event_handler(my_reply, events.NewMessage( 40 | chats=chat_id, pattern=BOT_SET['命令别名']['reply'])) 41 | 42 | 43 | @jdbot.on(events.NewMessage(incoming=True, chats=chat_id)) 44 | async def resp(event): 45 | try: 46 | if event.reply_to: 47 | reply = await event.get_reply_message() 48 | if reply.fwd_from.from_id: 49 | await jdbot.send_message(reply.fwd_from.from_id.user_id, event.message.text) 50 | else: 51 | await jdbot.send_message(chat_id, '不能获取到对方的id,请使用/reply进行回复') 52 | except Exception as e: 53 | await jdbot.send_message(chat_id, str(e)) 54 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/forward.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from .. import jdbot, chat_id, BOT_SET, ch_name 3 | import random 4 | 5 | 6 | @jdbot.on(events.NewMessage()) 7 | async def my_forward(event): 8 | try: 9 | if BOT_SET['开启机器人转发'].lower() != 'false' and event.chat_id != chat_id and str(event.chat_id) not in BOT_SET[ 10 | '机器人黑名单']: 11 | await jdbot.send_message(chat_id, f'您的机器人接收到消息。来自:```{event.chat_id}```') 12 | await jdbot.forward_messages(chat_id, event.id, event.chat_id) 13 | elif BOT_SET['开启机器人转发'].lower() != 'false' and str(event.chat_id) in BOT_SET['机器人黑名单']: 14 | words = BOT_SET['机器人垃圾话'].split('|') 15 | word = words[random.randint(0, len(words) - 1)] 16 | await jdbot.send_message(event.chat_id, str(word)) 17 | except Exception as e: 18 | await jdbot.send_message(chat_id, str(e)) 19 | 20 | 21 | @jdbot.on(events.NewMessage(chats=chat_id, pattern=r'^/reply')) 22 | async def my_reply(event): 23 | try: 24 | msg_text = event.raw_text.split(' ') 25 | if isinstance(msg_text, list) and len(msg_text) == 3: 26 | text = msg_text[1:] 27 | else: 28 | text = None 29 | if not text: 30 | info = '使用方法:/reply 123455676 你想说的话' 31 | await jdbot.send_message(chat_id, info) 32 | else: 33 | await jdbot.send_message(int(text[0]), text[1]) 34 | except Exception as e: 35 | await jdbot.send_message(chat_id, str(e)) 36 | 37 | 38 | if ch_name: 39 | jdbot.add_event_handler(my_reply, events.NewMessage( 40 | chats=chat_id, pattern=BOT_SET['命令别名']['reply'])) 41 | 42 | 43 | @jdbot.on(events.NewMessage(incoming=True, chats=chat_id)) 44 | async def resp(event): 45 | try: 46 | if event.reply_to: 47 | reply = await event.get_reply_message() 48 | if reply.fwd_from.from_id: 49 | await jdbot.send_message(reply.fwd_from.from_id.user_id, event.message.text) 50 | else: 51 | await jdbot.send_message(chat_id, '不能获取到对方的id,请使用/reply进行回复') 52 | except Exception as e: 53 | await jdbot.send_message(chat_id, str(e)) 54 | -------------------------------------------------------------------------------- /backup/2021-07-18/uninstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir 11 | from ..bot.utils import split_list, row, press_event, V4, QL 12 | from telethon import events, Button 13 | from asyncio import exceptions 14 | import os 15 | 16 | 17 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/uninstall$')) 18 | async def myuninstall(event): 19 | try: 20 | SENDER = event.sender_id 21 | mydiy = { 22 | "checkcookie.py": "检查账号过期", 23 | "upbot.py": "升级机器人", 24 | "download.py": "下载文件", 25 | "addrepo.py": "添加仓库", 26 | "addexport.py": "添加环境变量", 27 | "editexport.py": "修改环境变量", 28 | "user.py": "user.py" 29 | } 30 | btns = [] 31 | dirs = os.listdir(f"{_JdbotDir}/diy") 32 | for dir in dirs: 33 | if dir in mydiy: 34 | btns.append(Button.inline(mydiy[f'{dir}'], data=dir)) 35 | btns.append(Button.inline("帮我取消对话", data='cancel')) 36 | async with jdbot.conversation(SENDER, timeout=60) as conv: 37 | msg = await conv.send_message("请问你需要删除哪个功能?", buttons=split_list(btns, row)) 38 | convdata = await conv.wait_event(press_event(SENDER)) 39 | fname = bytes.decode(convdata.data) 40 | if fname == 'cancel': 41 | await jdbot.edit_message(msg, '对话已取消,感谢你的使用') 42 | conv.cancel() 43 | return 44 | conv.cancel() 45 | fpath = f"{_JdbotDir}/diy/{fname}" 46 | os.system(f'rm -rf {fpath}') 47 | if not os.path.isfile(fpath): 48 | await jdbot.edit_message(msg, "删除成功,正在自动重启") 49 | else: 50 | await jdbot.edit_message(msg, f"删除失败,请手动删除{fpath}文件") 51 | except exceptions.TimeoutError: 52 | msg = await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 53 | except Exception as e: 54 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 55 | logger.error('something wrong,I\'m sorry\n' + str(e)) 56 | 57 | -------------------------------------------------------------------------------- /backup/2021-07-19/uninstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : Chiupam 4 | # @Data : 2021-06-20 5 | # @Version : v 1.0 6 | # @Updata : 7 | # @Future : 8 | 9 | 10 | from .. import chat_id, jdbot, logger, _JdbotDir 11 | from ..bot.utils import split_list, row, press_event, V4, QL 12 | from telethon import events, Button 13 | from asyncio import exceptions 14 | import os 15 | 16 | 17 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/uninstall$')) 18 | async def myuninstall(event): 19 | try: 20 | SENDER = event.sender_id 21 | mydiy = { 22 | "checkcookie.py": "检查账号过期", 23 | "upbot.py": "升级机器人", 24 | "download.py": "下载文件", 25 | "addrepo.py": "添加仓库", 26 | "addexport.py": "添加环境变量", 27 | "editexport.py": "修改环境变量", 28 | "user.py": "user.py" 29 | } 30 | btns = [] 31 | dirs = os.listdir(f"{_JdbotDir}/diy") 32 | for dir in dirs: 33 | if dir in mydiy: 34 | btns.append(Button.inline(mydiy[f'{dir}'], data=dir)) 35 | btns.append(Button.inline("帮我取消对话", data='cancel')) 36 | async with jdbot.conversation(SENDER, timeout=60) as conv: 37 | msg = await conv.send_message("请问你需要删除哪个功能?", buttons=split_list(btns, row)) 38 | convdata = await conv.wait_event(press_event(SENDER)) 39 | fname = bytes.decode(convdata.data) 40 | if fname == 'cancel': 41 | await jdbot.edit_message(msg, '对话已取消,感谢你的使用') 42 | conv.cancel() 43 | return 44 | conv.cancel() 45 | fpath = f"{_JdbotDir}/diy/{fname}" 46 | os.system(f'rm -rf {fpath}') 47 | if not os.path.isfile(fpath): 48 | await jdbot.edit_message(msg, "删除成功,正在自动重启") 49 | else: 50 | await jdbot.edit_message(msg, f"删除失败,请手动删除{fpath}文件") 51 | except exceptions.TimeoutError: 52 | msg = await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 53 | except Exception as e: 54 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 55 | logger.error('something wrong,I\'m sorry\n' + str(e)) 56 | 57 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/bot/start.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .. import jdbot, chat_id, ch_name 4 | from ..bot.utils import V4 5 | 6 | 7 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern='/start')) 8 | async def bot_start(event): 9 | """接收/start命令后执行程序""" 10 | if V4: 11 | msg = '''使用方法如下: 12 | /help 获取命令,可直接发送至botfather。 13 | /start 开始使用本程序。 14 | /restart 重启本程序。 15 | e 查看运行日志。 16 | /up 升级本程序。 17 | /ver 查看程序版本号。 18 | /user 启动TG监控。 19 | /a 使用你的自定义快捷按钮。 20 | /addcron 增加crontab命令。 21 | /clearboard 删除快捷输入按钮。 22 | /cmd 执行shell命令。 23 | /cron 进行cron管理。 24 | /edit 从目录选择文件并编辑,需要将编辑好信息全部发给BOT,BOT会根据你发的信息进行替换。建议仅编辑config或crontab.list,其他文件慎用!!! 25 | /getfile 获取/jd目录下文件。 26 | /log 查看脚本执行日志。 27 | /node 执行js脚本,输入/node xxxxx.js。建议使用snode命令。 28 | /set 设置。 29 | /setname 设置命令别名。 30 | /setshort 设置自定义按钮,每次设置会覆盖原设置。 31 | /snode 选择脚本执行,只能选择/scripts和/own目录下的脚本,选择完后直接后台运行。 32 | /repo 管理添加的仓库。 33 | /export 管理添加的环境变量。 34 | 35 | 此外,直接发送文件至BOT,会让您选择保存到目标文件夹,支持保存并运行。发送以 .git 结尾的链接开始添加仓库。发送以 .js .sh .py结尾的已raw链接开始下载文件。发送格式为 key="value" 或者 key='value' 的消息开始添加环境变量。''' 36 | else: 37 | msg = '''使用方法如下: 38 | /help 获取命令,可直接发送至botfather。 39 | /start 开始使用本程序。 40 | /restart 重启本程序。 41 | e 查看运行日志。 42 | /up 升级本程序。 43 | /ver 查看程序版本号。 44 | /user 启动TG监控。 45 | /a 使用你的自定义快捷按钮。 46 | /addcron 增加crontab命令。 47 | /clearboard 删除快捷输入按钮。 48 | /cmd 执行shell命令。 49 | /cron 进行cron管理。 50 | /edit 从目录选择文件并编辑,需要将编辑好信息全部发给BOT,BOT会根据你发的信息进行替换。 51 | /env 环境变量管理,仅支持青龙面板。 52 | /getfile 获取/ql目录下文件。 53 | /log 查看脚本执行日志。 54 | /node 执行js脚本,输入/node xxxxx.js。建议使用snode命令。 55 | /set 设置。 56 | /setname 设置命令别名。 57 | /setshort 设置自定义按钮,每次设置会覆盖原设置。 58 | /snode 选择脚本执行,只能选择/scripts和/own目录下的脚本,选择完后直接后台运行。 59 | /repo 管理添加的仓库。 60 | /addenv 青龙新增环境变量。 61 | /env 青龙管理环境变量。 62 | 63 | 此外,直接发送文件至BOT,会让您选择保存到目标文件夹,支持保存并运行。发送以 .git 结尾的链接开始添加仓库。发送以 .js .sh .py结尾的已raw链接开始下载文件。发送格式为 key="value" 或者 key='value' 的消息开始添加环境变量。''' 64 | await jdbot.send_message(chat_id, msg) 65 | 66 | if ch_name: 67 | jdbot.add_event_handler(bot_start,events.NewMessage(from_users=chat_id, pattern='开始')) 68 | -------------------------------------------------------------------------------- /backup/2021-07-25/uninstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, _JdbotDir, chname, mybot 6 | from ..bot.utils import split_list, row, press_event, V4, QL 7 | from telethon import events, Button 8 | from asyncio import exceptions 9 | import os 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/uninstall$')) 13 | async def myuninstall(event): 14 | try: 15 | SENDER = event.sender_id 16 | mydiy = { 17 | "checkcookie.py": "检查账号过期", 18 | "upbot.py": "升级机器人", 19 | "download.py": "下载文件", 20 | "addrepo.py": "添加仓库", 21 | "addexport.py": "添加环境变量", 22 | "editexport.py": "修改环境变量", 23 | "user.py": "user.py" 24 | } 25 | btns = [] 26 | dirs = os.listdir(f"{_JdbotDir}/diy") 27 | for dir in dirs: 28 | if dir in mydiy: 29 | btns.append(Button.inline(mydiy[f'{dir}'], data=dir)) 30 | btns.append(Button.inline("帮我取消对话", data='cancel')) 31 | async with jdbot.conversation(SENDER, timeout=60) as conv: 32 | msg = await conv.send_message("请问你需要删除哪个功能?", buttons=split_list(btns, row)) 33 | convdata = await conv.wait_event(press_event(SENDER)) 34 | fname = bytes.decode(convdata.data) 35 | if fname == 'cancel': 36 | await jdbot.edit_message(msg, '对话已取消,感谢你的使用') 37 | conv.cancel() 38 | return 39 | conv.cancel() 40 | fpath = f"{_JdbotDir}/diy/{fname}" 41 | os.system(f'rm -rf {fpath}') 42 | if not os.path.isfile(fpath): 43 | await jdbot.edit_message(msg, "删除成功,正在自动重启") 44 | else: 45 | await jdbot.edit_message(msg, f"删除失败,请手动删除{fpath}文件") 46 | except exceptions.TimeoutError: 47 | msg = await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 48 | except Exception as e: 49 | await jdbot.send_message(chat_id, 'something wrong,I\'m sorry\n' + str(e)) 50 | logger.error('something wrong,I\'m sorry\n' + str(e)) 51 | 52 | 53 | if chname: 54 | jdbot.add_event_handler(myuninstall, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import asyncio 6 | import datetime 7 | import os 8 | import re 9 | 10 | from .. import chat_id, jdbot, logger, LOG_DIR 11 | 12 | 13 | async def execute(msg, info, exectext): 14 | """ 15 | 执行命令 16 | """ 17 | try: 18 | info += f'\n\n==========📣开始执行脚本📣=========\n' 19 | msg = await msg.edit(info) 20 | p = await asyncio.create_subprocess_shell(exectext, shell=True, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, env=os.environ) 21 | res_bytes, res_err = await p.communicate() 22 | res = res_bytes.decode('utf-8') 23 | if len(res) == 0: 24 | info += '\n已执行,但返回值为空' 25 | await msg.edit(info) 26 | return 27 | else: 28 | try: 29 | logtime = f'执行时间:' + re.findall(r'脚本执行- 北京时间.UTC.8.:(.*?)=', res, re.S)[0] + '\n' 30 | info += logtime 31 | except: 32 | pass 33 | errinfo = '\n\n**——‼错误代码493,IP可能黑了‼——**\n' if re.search('Response code 493', res) else '' 34 | if len(info + res + errinfo) <= 4000: 35 | await msg.edit(info + res + errinfo) 36 | elif len(info + res + errinfo) > 4000: 37 | tmp_log = f'{LOG_DIR}/bot/{exectext.split("/")[-1].split(".js")[0].split(".py")[0].split(".sh")[0].split(".ts")[0].split(" ")[-1]}-{datetime.datetime.now().strftime("%H-%M-%S.%f")}.log' 38 | with open(tmp_log, 'w+', encoding='utf-8') as f: 39 | f.write(res) 40 | await msg.delete() 41 | await jdbot.send_message(chat_id, f'{info}\n执行结果较长,请查看日志{errinfo}', file=tmp_log) 42 | os.remove(tmp_log) 43 | except Exception as e: 44 | title = "【💥错误💥】" 45 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 46 | function = "函数名:" + e.__traceback__.tb_frame.f_code.co_name 47 | details = "错误详情:第 " + str(e.__traceback__.tb_lineno) + " 行" 48 | tip = '建议百度/谷歌进行查询' 49 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n{details}\n{traceback.format_exc()}\n{tip}") 50 | logger.error(f"错误--->{str(e)}") -------------------------------------------------------------------------------- /beta/bot/start.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | 3 | from .. import jdbot, chat_id, ch_name 4 | from ..bot.utils import V4 5 | 6 | 7 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern='/start')) 8 | async def bot_start(event): 9 | """接收/start命令后执行程序""" 10 | if V4: 11 | msg = '''使用方法如下: 12 | /help 获取命令,可直接发送至 @BotFather 。 13 | /start 开始使用本程序。 14 | /restart 重启本程序。 15 | e 查看运行日志。 16 | /up 升级本程序。 17 | /ver 查看程序版本号。 18 | /user 启动TG监控。 19 | /a 使用你的自定义快捷按钮。 20 | /addcron 增加crontab命令。 21 | /clearboard 删除快捷输入按钮。 22 | /blockcookie 屏蔽cookie操作。 23 | /checkcookie 检测cookie过期。 24 | /cmd 执行shell命令。 25 | /cron 进行cron管理。 26 | /edit 从目录选择文件并编辑,需要将编辑好信息全部发给BOT,BOT会根据你发的信息进行替换。建议仅编辑config或crontab.list,其他文件慎用!!! 27 | /getfile 获取/jd目录下文件。 28 | /log 查看脚本执行日志。 29 | /node 执行js脚本,输入/node xxxxx.js。建议使用snode命令。 30 | /set 设置。 31 | /setname 设置命令别名。 32 | /setshort 设置自定义按钮,每次设置会覆盖原设置。 33 | /snode 选择脚本执行,只能选择/scripts和/own目录下的脚本,选择完后直接后台运行。 34 | /repo 管理添加的仓库。 35 | /export 管理添加的环境变量。 36 | 37 | 此外,直接发送文件至BOT,会让您选择保存到目标文件夹,支持保存并运行。发送以 .git 结尾的链接开始添加仓库。发送以 .js .sh .py结尾的已raw链接开始下载文件。发送格式为 key="value" 或者 key='value' 的消息开始添加环境变量。''' 38 | else: 39 | msg = '''使用方法如下: 40 | /help 获取命令,可直接发送至botfather。 41 | /start 开始使用本程序。 42 | /restart 重启本程序。 43 | e 查看运行日志。 44 | /up 升级本程序。 45 | /ver 查看程序版本号。 46 | /user 启动TG监控。 47 | /a 使用你的自定义快捷按钮。 48 | /addcron 增加crontab命令。 49 | /clearboard 删除快捷输入按钮。 50 | /blockcookie 屏蔽cookie操作。 51 | /checkcookie 检测cookie过期。 52 | /cmd 执行shell命令。 53 | /cron 进行cron管理。 54 | /edit 从目录选择文件并编辑,需要将编辑好信息全部发给BOT,BOT会根据你发的信息进行替换。 55 | /env 环境变量管理,仅支持青龙面板。 56 | /getfile 获取/ql目录下文件。 57 | /log 查看脚本执行日志。 58 | /node 执行js脚本,输入/node xxxxx.js。建议使用snode命令。 59 | /set 设置。 60 | /setname 设置命令别名。 61 | /setshort 设置自定义按钮,每次设置会覆盖原设置。 62 | /snode 选择脚本执行,只能选择/scripts和/own目录下的脚本,选择完后直接后台运行。 63 | /repo 管理添加的仓库。 64 | /addenv 青龙新增环境变量。 65 | /env 青龙管理环境变量。 66 | 67 | 此外,直接发送文件至BOT,会让您选择保存到目标文件夹,支持保存并运行。发送以 .git 结尾的链接开始添加仓库。发送以 .js .sh .py结尾的已raw链接开始下载文件。发送格式为 key="value" 或者 key='value' 的消息开始添加环境变量。''' 68 | await jdbot.send_message(chat_id, msg) 69 | 70 | if ch_name: 71 | jdbot.add_event_handler(bot_start,events.NewMessage(from_users=chat_id, pattern='开始')) 72 | -------------------------------------------------------------------------------- /shell/fix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ ! -d "/ql" ];then root=/jd; else root=/ql;fi 4 | 5 | restart() { 6 | if [ -d "/ql" ]; then 7 | ps -ef | grep "python3 -m jbot" | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null 8 | nohup python3 -m jbot > $root/log/bot/bot.log 2>&1 & 9 | else 10 | cd $root/jbot || exit; pm2 start ecosystem.config.js 11 | cd $root || exit; pm2 restart jbot 12 | fi 13 | } 14 | 15 | fix1() { 16 | rm -f $root/bot.session 17 | rm -f $root/bot.session-journal 18 | rm -f $root/user.session 19 | rm -f $root/user.session-journal 20 | rm -f $root/config/user.session 21 | rm -f $root/config/user.session-journal 22 | sed -i 's/user": "True"/user": "False"/' $root/config/botset.json 23 | restart 24 | } 25 | 26 | fix2() { 27 | if [ -d "/jd" ]; then root=/jd; else root=/ql; fi 28 | rm -f $root/user.session 29 | rm -f $root/user.session-journal 30 | rm -f $root/config/user.session 31 | rm -f $root/config/user.session-journal 32 | sed -i 's/user": "True"/user": "False"/' $root/config/botset.json 33 | restart 34 | } 35 | 36 | fix3() { 37 | if [ -d "/jd" ]; then root=/jd; else root=/ql; fi 38 | python3 $root/repo/diybot/other/upgrade_all_packages.py 39 | rm -rf $root/jbot/__pycache__ 40 | rm -rf $root/jbot/bot/__pycache__ 41 | rm -rf $root/jbot/diy/__pycache__ 42 | rm -rf $root/jbot/user/__pycache__ 43 | restart 44 | } 45 | 46 | back() { 47 | if [ -d $root/repo/backup ]; then 48 | echo "无法恢复user的正常监控!请悉知!" 49 | cd $root/repo/backup || exit 50 | dir=$(ls -t | head -1 | awk '{print $1}') 51 | rm -rf $root/jbot/* 52 | cp -rf "${root}/repo/backup/${dir}/*" $root/jbot 53 | cd $root/jbot || exit; pm2 start ecosystem.config.js 54 | cd $root; pm2 restart jbot 55 | else 56 | echo "你没有做备份!无法回滚!" 57 | fi 58 | } 59 | 60 | main() { 61 | echo "请选择您需要进行的操作:" 62 | echo " 1) 重装机器人后 /start 没有反应" 63 | echo " 2) /user 点击 开启user 按钮后连 /start 都没有反应" 64 | echo " 3) 日志提示:AttributeError: module 'xxxxxx' has no attribute 'xxxxxx'" 65 | echo " 4) 想用回之前自己最后一次备份好的机器人文件(可能无法使用user监控)" 66 | echo " 5) 退出修复脚本" 67 | echo "" 68 | echo -n "请输入编号: " 69 | read N 70 | case $N in 71 | 1) fix1 ;; 72 | 2) fix2 ;; 73 | 3) fix3 ;; 74 | 4) back ;; 75 | 5) exit 0 ;; 76 | *) echo "输入错误!"; sleep 1s; main;; 77 | esac 78 | } 79 | 80 | main 81 | exit 0 82 | -------------------------------------------------------------------------------- /beta/user/redrain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import datetime 6 | import os 7 | import re 8 | import sys 9 | import time 10 | 11 | from telethon import events 12 | 13 | from .login import user 14 | from .. import chat_id, jdbot, logger, JD_DIR, TOKEN 15 | from ..bot.utils import cmd 16 | from ..diy.utils import my_chat_id 17 | 18 | bot_id = int(TOKEN.split(":")[0]) 19 | client = user 20 | 21 | 22 | @client.on(events.NewMessage(chats=[-1001159808620, my_chat_id], pattern=r".*京豆雨.*")) 23 | async def red(event): 24 | """ 25 | 龙王庙京豆雨 26 | 关注频道:https://t.me/longzhuzhu 27 | """ 28 | try: 29 | file = "jredrain.sh" 30 | if not os.path.exists(f'{JD_DIR}/{file}'): 31 | cmdtext = f'cd {JD_DIR} && wget https://raw.githubusercontent.com/chiupam/JD_Diy/master/other/{file}' 32 | await cmd(cmdtext) 33 | if not os.path.exists(f'{JD_DIR}/{file}'): 34 | await jdbot.send_message(chat_id, f"【龙王庙】\n\n监控到RRA,但是缺少{file}文件,无法执行定时") 35 | return 36 | message = event.message.text 37 | RRAs = re.findall(r'RRA.*', message) 38 | Times = re.findall(r'开始时间.*', message) 39 | for RRA in RRAs: 40 | i = RRAs.index(RRA) 41 | cmdtext = f"/cmd bash {JD_DIR}/{file} {RRA}" 42 | Time_1 = Times[i].split(" ")[0].split("-") 43 | Time_2 = Times[i].split(" ")[1].split(":") 44 | Time_3 = time.localtime() 45 | year, mon, mday = Time_3[0], Time_3[1], Time_3[2] 46 | if int(Time_2[0]) >= 8: 47 | await client.send_message(bot_id, cmdtext, schedule=datetime.datetime(year, int(Time_1[1]), int(Time_1[2]), int(Time_2[0]) - 8, int(Time_2[1]), 0, 0)) 48 | else: 49 | await client.send_message(bot_id, cmdtext, schedule=datetime.datetime(year, int(Time_1[1]), int(Time_1[2]) - 1, int(Time_2[0]) + 16, int(Time_2[1]), 0, 0)) 50 | await jdbot.send_message(chat_id, f'监控到RRA:{RRA}\n预定时间:{Times[i].split(":")[1]}\n\n将在预定时间执行脚本,具体请查看当前机器人的定时任务') 51 | except Exception as e: 52 | title = "【💥错误💥】" 53 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 54 | function = "函数名:" + sys._getframe().f_code.co_name 55 | tip = '建议百度/谷歌进行查询' 56 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 57 | logger.error(f"错误--->{str(e)}") 58 | -------------------------------------------------------------------------------- /backup/2022-01-03/jbot/user/redrain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import datetime 6 | import os 7 | import re 8 | import sys 9 | import time 10 | 11 | from telethon import events 12 | 13 | from .login import user 14 | from .. import chat_id, jdbot, logger, JD_DIR, TOKEN 15 | from ..bot.utils import cmd 16 | from ..diy.utils import my_chat_id 17 | 18 | bot_id = int(TOKEN.split(":")[0]) 19 | client = user 20 | 21 | 22 | @client.on(events.NewMessage(chats=[-1001159808620, my_chat_id], pattern=r".*京豆雨.*")) 23 | async def red(event): 24 | """ 25 | 龙王庙京豆雨 26 | 关注频道:https://t.me/longzhuzhu 27 | """ 28 | try: 29 | file = "jredrain.sh" 30 | if not os.path.exists(f'{JD_DIR}/{file}'): 31 | cmdtext = f'cd {JD_DIR} && wget https://raw.githubusercontent.com/chiupam/JD_Diy/master/other/{file}' 32 | await cmd(cmdtext) 33 | if not os.path.exists(f'{JD_DIR}/{file}'): 34 | await jdbot.send_message(chat_id, f"【龙王庙】\n\n监控到RRA,但是缺少{file}文件,无法执行定时") 35 | return 36 | message = event.message.text 37 | RRAs = re.findall(r'RRA.*', message) 38 | Times = re.findall(r'开始时间.*', message) 39 | for RRA in RRAs: 40 | i = RRAs.index(RRA) 41 | cmdtext = f"/cmd bash {JD_DIR}/{file} {RRA}" 42 | Time_1 = Times[i].split(" ")[0].split("-") 43 | Time_2 = Times[i].split(" ")[1].split(":") 44 | Time_3 = time.localtime() 45 | year, mon, mday = Time_3[0], Time_3[1], Time_3[2] 46 | if int(Time_2[0]) >= 8: 47 | await client.send_message(bot_id, cmdtext, schedule=datetime.datetime(year, int(Time_1[1]), int(Time_1[2]), int(Time_2[0]) - 8, int(Time_2[1]), 0, 0)) 48 | else: 49 | await client.send_message(bot_id, cmdtext, schedule=datetime.datetime(year, int(Time_1[1]), int(Time_1[2]) - 1, int(Time_2[0]) + 16, int(Time_2[1]), 0, 0)) 50 | await jdbot.send_message(chat_id, f'监控到RRA:{RRA}\n预定时间:{Times[i].split(":")[1]}\n\n将在预定时间执行脚本,具体请查看当前机器人的定时任务') 51 | except Exception as e: 52 | title = "【💥错误💥】" 53 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 54 | function = "函数名:" + sys._getframe().f_code.co_name 55 | tip = '建议百度/谷歌进行查询' 56 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 57 | logger.error(f"错误--->{str(e)}") 58 | -------------------------------------------------------------------------------- /beta/user/activityID.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import os 6 | import re 7 | import traceback 8 | 9 | from telethon import events 10 | 11 | from .login import user 12 | from .utils import execute 13 | from .. import chat_id, jdbot, logger, TOKEN, OWN_DIR 14 | from ..bot.utils import TASK_CMD 15 | from ..diy.utils import myzdjr_chatIds 16 | 17 | bot_id = int(TOKEN.split(":")[0]) 18 | client = user 19 | 20 | 21 | @client.on(events.NewMessage(chats=myzdjr_chatIds, pattern=r'export\s(jd_zdjr_activity|jd_joinTeam_activity|FAV|OPEN_CARD|addCart|luckDraw).*=(".*"|\'.*\')')) 22 | async def activity(event): 23 | """ 24 | 监控运行变量 25 | """ 26 | try: 27 | msg = await jdbot.send_message(chat_id, '监控到活动变量') 28 | group = f'[{event.chat.title}](https://t.me/c/{event.chat.id}/{event.message.id})' 29 | if "jd_zdjr_activity" in event.message.text: 30 | name = '组队瓜分京豆' 31 | cmd = f'{TASK_CMD} {OWN_DIR}/smiek_jd_zdjr.js now' 32 | else: 33 | return 34 | messages = event.message.raw_text.split("\n") 35 | invalid, unchange = False, True 36 | for message in messages: 37 | if "export " not in message: 38 | continue 39 | kv = re.sub(r'.*export ', '', message) 40 | key = kv.split("=")[0] 41 | value = re.findall(r'"([^"]*)"', kv)[0] 42 | if "zdjr" in key and len(value) != 32: 43 | invalid = True 44 | elif os.environ.get(key) != value: 45 | os.environ[key] = value 46 | unchange = False 47 | if invalid: 48 | await msg.edit(f"监控到 {group} 的 **{name}** 活动,变量不正确停止运行……") 49 | return 50 | elif unchange: 51 | await msg.edit(f"监控到 {group} 的 **{name}** 活动,变量已重复停止运行……") 52 | return 53 | else: 54 | info = f"监控到 {group} 的 **{name}** 活动" 55 | await execute(msg, info, cmd) 56 | except Exception as e: 57 | title = "【💥错误💥】" 58 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 59 | function = "函数名:" + e.__traceback__.tb_frame.f_code.co_name 60 | details = "错误详情:第 " + str(e.__traceback__.tb_lineno) + " 行" 61 | tip = '建议百度/谷歌进行查询' 62 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n{details}\n{traceback.format_exc()}\n{tip}") 63 | logger.error(f"错误--->{str(e)}") 64 | -------------------------------------------------------------------------------- /beta/bot/up.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from asyncio import exceptions 4 | 5 | import requests 6 | from telethon import events, Button 7 | 8 | from .update import version, botlog 9 | from .. import chat_id, jdbot, logger, JD_DIR, BOT_SET 10 | from ..bot.utils import press_event 11 | 12 | 13 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/upbot$')) 14 | async def myupbot(event): 15 | try: 16 | SENDER = event.sender.id 17 | buttons = [Button.inline("是", "yes"), Button.inline("取消", "cancel")] 18 | async with jdbot.conversation(SENDER, timeout=180) as conversation: 19 | msg = await conversation.send_message("前瞻计划及其不稳定,确定需要升级吗?", buttons=buttons) 20 | byte = await conversation.wait_event(press_event(SENDER)) 21 | res = bytes.decode(byte.data) 22 | if res == "cancel": 23 | await jdbot.edit_message(msg, "取消升级") 24 | return 25 | else: 26 | await jdbot.delete_messages(chat_id, msg) 27 | conversation.cancel() 28 | msg = await jdbot.send_message(chat_id, "【前瞻计划】\n\n准备更新程序") 29 | url = "https://raw.githubusercontent.com/chiupam/JD_Diy/master/shell/bot_beta.sh" 30 | if '下载代理' in BOT_SET.keys() and str(BOT_SET['下载代理']).lower() != 'false' and 'github' in url: 31 | url = f'{str(BOT_SET["下载代理"])}/{url}' 32 | resp = requests.get(url).text 33 | if "#!/usr/bin/env bash" not in resp: 34 | await jdbot.edit_message(msg, "【前瞻计划】\n\n下载shell文件失败\n请稍后重试,或尝试关闭代理重启") 35 | return 36 | with open(f"{JD_DIR}/bot.sh", 'w+', encoding='utf-8') as f: 37 | f.write(resp) 38 | text = "【前瞻计划】\n\n更新过程中程序会重启,请耐心等待……\n为安全起见,关闭user监控,请使用 /user 手动开启!" 39 | await jdbot.edit_message(msg, text) 40 | os.system(f"bash {JD_DIR}/bot.sh") 41 | except exceptions.TimeoutError: 42 | await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 43 | except Exception as e: 44 | title = "【💥错误💥】" 45 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 46 | function = "函数名:" + sys._getframe().f_code.co_name 47 | tip = '建议百度/谷歌进行查询' 48 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 49 | logger.error(f"错误--->{str(e)}") 50 | 51 | 52 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/ver$', incoming=True)) 53 | async def bot_ver(event): 54 | await jdbot.send_message(chat_id, f'当前版本\n{version}\n{botlog}') 55 | -------------------------------------------------------------------------------- /backup/2021-08-23/upbot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from .. import chat_id, jdbot, logger, _JdDir, _JdbotDir, chname, mybot 6 | from ..bot.utils import press_event, split_list, row 7 | from telethon import events, Button 8 | from asyncio import exceptions 9 | import requests, os, sys 10 | 11 | 12 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/upbot$')) 13 | async def myupbot(event): 14 | try: 15 | msg = await jdbot.send_message(chat_id, "【diy正式版】\n\n准备更新程序") 16 | SENDER = event.sender_id 17 | furl = "https://raw.githubusercontent.com/chiupam/JD_Diy/master/config/diybot.sh" 18 | if '下载代理' in mybot.keys() and str(mybot['下载代理']).lower() != 'false' and 'github' in furl: 19 | furl = f'{str(mybot["下载代理"])}/{furl}' 20 | resp = requests.get(furl).text 21 | if not resp: 22 | await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件失败\n请稍后重试,或尝试关闭代理重启") 23 | return 24 | cmdtext = f"bash {_JdDir}/diybot.sh" 25 | if os.path.exists(f'{_JdbotDir}/diy/user.py'): 26 | btns = [ 27 | Button.inline("更新", data="user"), 28 | Button.inline("不更新", data="no") 29 | ] 30 | async with jdbot.conversation(SENDER, timeout=60) as conv: 31 | msg = await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件成功\n是否更新 user.py?(覆盖式更新)", buttons=split_list(btns, row)) 32 | convdata = await conv.wait_event(press_event(SENDER)) 33 | res = bytes.decode(convdata.data) 34 | if res == "user": 35 | cmdtext = f"bash {_JdDir}/diybot.sh {res}" 36 | conv.cancel() 37 | fpath = f"{_JdDir}/diybot.sh" 38 | with open(fpath, 'w+', encoding='utf-8') as f: 39 | f.write(resp) 40 | await jdbot.edit_message(msg, "更新过程中程序会重启,请耐心等待") 41 | os.system(cmdtext) 42 | except exceptions.TimeoutError: 43 | await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 44 | except Exception as e: 45 | title = "【💥错误💥】" 46 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 47 | function = "函数名:" + sys._getframe().f_code.co_name 48 | tip = '建议百度/谷歌进行查询' 49 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 50 | logger.error(f"错误--->{str(e)}") 51 | 52 | 53 | if chname: 54 | jdbot.add_event_handler(myupbot, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) -------------------------------------------------------------------------------- /jbot/diy/upbot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from asyncio import exceptions 6 | 7 | import os 8 | import requests 9 | import sys 10 | from telethon import events, Button 11 | 12 | from .. import chat_id, jdbot, logger, JD_DIR, BOT_DIR, ch_name, BOT_SET 13 | from ..bot.utils import press_event, split_list, row 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/upbot$')) 17 | async def myupbot(event): 18 | try: 19 | msg = await jdbot.send_message(chat_id, "【diy正式版】\n\n准备更新程序") 20 | SENDER = event.sender_id 21 | furl = "https://raw.githubusercontent.com/chiupam/JD_Diy/master/shell/diybot.sh" 22 | if '下载代理' in BOT_SET.keys() and str(BOT_SET['下载代理']).lower() != 'false' and 'github' in furl: 23 | furl = f'{str(BOT_SET["下载代理"])}/{furl}' 24 | resp = requests.get(furl).text 25 | if not resp: 26 | await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件失败\n请稍后重试,或尝试关闭代理重启") 27 | return 28 | cmdtext = f"bash {JD_DIR}/diybot.sh" 29 | if os.path.exists(f'{BOT_DIR}/diy/user.py'): 30 | btns = [ 31 | Button.inline("更新", data="user"), 32 | Button.inline("不更新", data="no") 33 | ] 34 | async with jdbot.conversation(SENDER, timeout=60) as conv: 35 | msg = await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件成功\n是否更新 user.py?(覆盖式更新)", buttons=split_list(btns, row)) 36 | convdata = await conv.wait_event(press_event(SENDER)) 37 | res = bytes.decode(convdata.data) 38 | if res == "user": 39 | cmdtext = f"bash {JD_DIR}/diybot.sh {res}" 40 | conv.cancel() 41 | fpath = f"{JD_DIR}/diybot.sh" 42 | with open(fpath, 'w+', encoding='utf-8') as f: 43 | f.write(resp) 44 | await jdbot.edit_message(msg, "更新过程中程序会重启,请耐心等待") 45 | os.system(cmdtext) 46 | except exceptions.TimeoutError: 47 | await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 48 | except Exception as e: 49 | title = "【💥错误💥】" 50 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 51 | function = "函数名:" + sys._getframe().f_code.co_name 52 | tip = '建议百度/谷歌进行查询' 53 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 54 | logger.error(f"错误--->{str(e)}") 55 | 56 | 57 | if ch_name: 58 | jdbot.add_event_handler(myupbot, events.NewMessage(from_users=chat_id, pattern=BOT_SET['命令别名']['cron'])) -------------------------------------------------------------------------------- /backup/2021-09-04/upbot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | from asyncio import exceptions 6 | 7 | import os 8 | import requests 9 | import sys 10 | from telethon import events, Button 11 | 12 | from .. import chat_id, jdbot, logger, _JdDir, _JdbotDir, chname, mybot 13 | from ..bot.utils import press_event, split_list, row 14 | 15 | 16 | @jdbot.on(events.NewMessage(from_users=chat_id, pattern=r'^/upbot$')) 17 | async def myupbot(event): 18 | try: 19 | msg = await jdbot.send_message(chat_id, "【diy正式版】\n\n准备更新程序") 20 | SENDER = event.sender_id 21 | furl = "https://raw.githubusercontent.com/chiupam/JD_Diy/master/config/diybot.sh" 22 | if '下载代理' in mybot.keys() and str(mybot['下载代理']).lower() != 'false' and 'github' in furl: 23 | furl = f'{str(mybot["下载代理"])}/{furl}' 24 | resp = requests.get(furl).text 25 | if not resp: 26 | await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件失败\n请稍后重试,或尝试关闭代理重启") 27 | return 28 | cmdtext = f"bash {_JdDir}/diybot.sh" 29 | if os.path.exists(f'{_JdbotDir}/diy/user.py'): 30 | btns = [ 31 | Button.inline("更新", data="user"), 32 | Button.inline("不更新", data="no") 33 | ] 34 | async with jdbot.conversation(SENDER, timeout=60) as conv: 35 | msg = await jdbot.edit_message(msg, "【diy正式版】\n\n下载shell文件成功\n是否更新 user.py?(覆盖式更新)", buttons=split_list(btns, row)) 36 | convdata = await conv.wait_event(press_event(SENDER)) 37 | res = bytes.decode(convdata.data) 38 | if res == "user": 39 | cmdtext = f"bash {_JdDir}/diybot.sh {res}" 40 | conv.cancel() 41 | fpath = f"{_JdDir}/diybot.sh" 42 | with open(fpath, 'w+', encoding='utf-8') as f: 43 | f.write(resp) 44 | await jdbot.edit_message(msg, "更新过程中程序会重启,请耐心等待") 45 | os.system(cmdtext) 46 | except exceptions.TimeoutError: 47 | await jdbot.edit_message(msg, '选择已超时,对话已停止,感谢你的使用') 48 | except Exception as e: 49 | title = "【💥错误💥】" 50 | name = "文件名:" + os.path.split(__file__)[-1].split(".")[0] 51 | function = "函数名:" + sys._getframe().f_code.co_name 52 | tip = '建议百度/谷歌进行查询' 53 | await jdbot.send_message(chat_id, f"{title}\n\n{name}\n{function}\n错误原因:{str(e)}\n\n{tip}") 54 | logger.error(f"错误--->{str(e)}") 55 | 56 | 57 | if chname: 58 | jdbot.add_event_handler(myupbot, events.NewMessage(from_users=chat_id, pattern=mybot['命令别名']['cron'])) --------------------------------------------------------------------------------