Skip to content

Commit

Permalink
Merge pull request #143 from AirportR/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AirportR authored Dec 17, 2023
2 parents 6602418 + 66d6f56 commit 552e55b
Show file tree
Hide file tree
Showing 25 changed files with 502 additions and 315 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: ci

on:
push:
branches:
- "dev"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Environment Variables
run: |
IMG=fulltclash
OWNER="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
echo "IMG=${IMG}" >> $GITHUB_ENV
echo "IMAGE=ghcr.io/${OWNER}/${IMG}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./docker/Dockerfile
push: true
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:dev
- name: Build alpine Docker
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./docker/Dockerfile.alpine
push: true
tags: |
${{ env.IMAGE }}:alpine
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ apt install -y git && git clone https://github.com/AirportR/FullTclash.git && cd
# 如果是在中国大陆地区使用,则程序需要代理才能连接上Telegram服务器。写入如下信息:
proxy: 127.0.0.1:7890 #socks5 替换成自己的代理地址和端口
```
- 代理客户端路径配置
从3.6.5版本开始,不再默认提供代理客户端二进制文件,请自行前往以下网址获取:
https://github.com/AirportR/FullTCore/releases \
下载解压后可以放到 ./bin/ 目录下,比如文件名为 FullTCore ,下面的配置文件这样写:
```yaml
clash:
path: "./bin/FullTCore" #这里改成代理客户端文件路径
```
Windows系统名字后缀名.exe要加上,其他类Unix系统不需要加后缀名。
- 代理配置(可选)
如果是在中国大陆地区使用,可能部分订阅网址无法直接连接。可在config.yaml中写入如下信息:
Expand Down Expand Up @@ -201,7 +211,7 @@ fulltclash-windows-amd64 为 Windows-amd64 所支持的

编译完成覆盖原文件即可 ,如果操作难度太大,可以发起issue详谈。
### Docker启动
教程文档待更新
[./docker/ 目录](https://github.com/AirportR/FullTclash/tree/dev/docker)
### 为程序设置进程守护(Linux)
由于Linux系统特性,关闭ssh连接后,前台程序会被关闭。您需要设置进程守护,才能在后台不间断地运行程序。具体方法Google搜索即可。
## 交流探讨
Expand Down
Empty file added bin/.gitkeep
Empty file.
Binary file removed bin/fulltclash-linux-amd64
Binary file not shown.
Binary file removed bin/fulltclash-macos-amd64
Binary file not shown.
Binary file removed bin/fulltclash-windows-amd64.exe
Binary file not shown.
27 changes: 24 additions & 3 deletions botmodule/cfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def exclude_text_filter(text: Union[str, List[str]]) -> "Filter":
text = [text] if isinstance(text, str) else text

async def func(flt, _, update: Union[Message, CallbackQuery]):
return update.data not in flt.text if isinstance(update, CallbackQuery) else\
return update.data not in flt.text if isinstance(update, CallbackQuery) else \
update.text and update.text not in flt.text

return filters.create(func, text=text)
Expand Down Expand Up @@ -156,6 +156,27 @@ def getErrorText(text: str):
return f"❌ 使用方式: \n{text} <参数1> <参数2>"


def sub_filter():
"""
对订阅名称做预先检查
"""
async def func(_, __, message: Message) -> bool:
string = str(message.text)
arg = string.strip().split(' ')
arg = [x for x in arg if x != '']
if arg[0].endswith("url") or 'invite' in arg[0]:
return True
if check.check_sub_name(arg[1]):
return True
else:
botmsg = await message.reply("❌找不到该任务名称")
message_delete_queue.put(botmsg, 10)
message_delete_queue.put(message, 10)
return False

return filters.create(func)


def command_argnum_filter(argnum: int = 1):
"""
命令行参数数量过滤器。
Expand Down Expand Up @@ -183,9 +204,9 @@ async def func(_, __, message: Message):
return filters.create(func)


def allfilter(group: int, *args):
def pre_filter(group: int, *args):
"""
所有自定义filter
预定义的filter
"""
if group == 1:
return command_argnum_filter(*args)
Expand Down
8 changes: 5 additions & 3 deletions botmodule/command/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ async def task_result(app: Client, message: Message):
info['slave'] = {'comment': slavecomment, 'id': int(slaveid)}
origin_message_d = resultdata.get('origin-message', {})
botmsg_d = resultdata.get('edit-message', {})
chat_id = origin_message_d.get('chat-id', 0)
try:
origin_msg = await app.get_messages(origin_message_d.get('chat-id', 0), origin_message_d.get('message-id', 0))
botmsg = await app.get_messages(botmsg_d.get('chat-id', 0), botmsg_d.get('message-id', 0))
origin_msg = await app.get_messages(chat_id, origin_message_d.get('message-id', 0))
botmsg = await app.get_messages(chat_id, botmsg_d.get('message-id', 0))
except RPCError as e:
logger.error(str(e))
return
Expand All @@ -205,4 +206,5 @@ async def task_result(app: Client, message: Message):
3: 'test',
-1: 'unknown'
}
await select_export(origin_msg, botmsg, puttype[resultdata.get('coreindex', -1)], info)
await select_export(app, origin_message_d.get('message-id', 0), botmsg_d.get('message-id', 0), chat_id,
puttype[resultdata.get('coreindex', -1)], info)
6 changes: 1 addition & 5 deletions botmodule/command/grant.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import os
import signal
import subprocess
import sys
import pyrogram.types
from loguru import logger
from pyrogram import Client
from pyrogram.errors import RPCError
from botmodule.init_bot import admin, config, reloadUser, proxy_subprocess
from botmodule.init_bot import admin, config, reloadUser
from utils.cron.utils import message_delete_queue
# from utils.proxys import killclash


async def grant(client: Client, message: pyrogram.types.Message):
Expand Down Expand Up @@ -110,8 +108,6 @@ async def user(_, message):

async def restart_or_killme(_, message, kill=False):
try:
if isinstance(proxy_subprocess, subprocess.Popen):
proxy_subprocess.kill()
if kill:
await message.reply("再见~")
os.kill(os.getpid(), signal.SIGINT)
Expand Down
Loading

0 comments on commit 552e55b

Please sign in to comment.