This repository has been archived by the owner on Dec 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
216 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
; 配置文件 | ||
; pip install pyserial | ||
; pip install telepot | ||
; pip install phone #归属地查询 | ||
; https://api.telegram.org/bot+id/getupdates | ||
|
||
[main] | ||
;手机号,不填不影响,在多开的情况下,填了方便区分。 | ||
current_phonenum=13512345678 | ||
;错误次数上限 | ||
max_error_count=100 | ||
|
||
[port] | ||
;串口号 | ||
serialPort=COM7 | ||
;波特率 | ||
baudRate=115200 | ||
;X秒未刷新,强制重新连接串口 | ||
schedule_reconnect_max=20.0 | ||
|
||
[sms] | ||
;允许发送短信吗 | ||
sms_send_allow=True | ||
;开启11位来电自动回复 | ||
sms_auto_send=False | ||
;自动回复短信的数量上限 | ||
sms_limit=1 | ||
;自动回复的内容 | ||
sms_auto_send_content=你好,有事情请联系。 | ||
|
||
|
||
[log] | ||
;是否在本地消息中显示本机号码 | ||
current_phonenum_log=True | ||
|
||
[telegram] | ||
;启用Telegram发送 | ||
tg_send_enable=True | ||
;启用Telegram接收 (新建线程)不建议开启,国内网络及其不稳定,除了专线。 | ||
tg_receive_enable=False | ||
;bot参数 | ||
bot=xxxxxx:xxxxxxxxxx | ||
;TG的群组 | ||
tg_chat_id=-xxx | ||
;是否在Telegram消息中显示本机号码 | ||
current_phonenum_tg=True | ||
;Telegram消息识别频率,单位为秒,不能小于5秒,否则默认为5秒 | ||
tg_read_period=60 | ||
;最新读取的信息ID | ||
tg_last_read_id=997629083 | ||
|
||
[common_input] | ||
;通用输入功能,通过运行目录下的common_input.txt 实现,仅读取第一行的命令,超出部分会删除,流程完毕会返回free在第一行,或者error和第二行错误信息。 | ||
common_input_function=True | ||
|
||
; 配置文件 | ||
; pip install pyserial | ||
; pip install telepot | ||
; pip install phone #归属地查询 | ||
; https://api.telegram.org/bot+id/getupdates | ||
|
||
[main] | ||
;手机号,不填不影响,在多开的情况下,填了方便区分。 | ||
current_phonenum=13512345678 | ||
;错误次数上限 | ||
max_error_count=100 | ||
|
||
[port] | ||
;串口号 | ||
serialPort=COM7 | ||
;波特率 | ||
baudRate=115200 | ||
;X秒未刷新,强制重新连接串口 | ||
schedule_reconnect_max=20.0 | ||
|
||
[sms] | ||
;允许发送短信吗 | ||
sms_send_allow=True | ||
;开启11位来电自动回复 | ||
sms_auto_send=False | ||
;自动回复短信的数量上限 | ||
sms_limit=1 | ||
;自动回复的内容 | ||
sms_auto_send_content=你好,有事情请联系。 | ||
|
||
|
||
[log] | ||
;是否在本地消息中显示本机号码 | ||
current_phonenum_log=True | ||
|
||
[telegram] | ||
;启用Telegram发送 | ||
tg_send_enable=True | ||
;启用Telegram接收 (新建线程)不建议开启,国内网络及其不稳定,除了专线。 | ||
tg_receive_enable=False | ||
;bot参数 | ||
bot=xxxxxx:xxxxxxxxxx | ||
;TG的群组 | ||
tg_chat_id=-xxx | ||
;是否在Telegram消息中显示本机号码 | ||
current_phonenum_tg=True | ||
;Telegram消息识别频率,单位为秒,不能小于5秒,否则默认为5秒 | ||
tg_read_period=60 | ||
;最新读取的信息ID | ||
tg_last_read_id=997629083 | ||
|
||
[common_input] | ||
;通用输入功能,通过运行目录下的common_input.txt 实现,仅读取第一行的命令,超出部分会删除,流程完毕会返回free在第一行,或者error和第二行错误信息。 | ||
common_input_function=True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
|
||
class tg_bot(object): | ||
def __init__(self, tg_api_base_link,bot_id): | ||
self.tg_api_base_link = tg_api_base_link | ||
self.bot_id=bot_id | ||
def getUpdates(self): | ||
error=0 | ||
while True: | ||
if error>5: | ||
return(False,"Too Many Errors") | ||
try: | ||
r=requests.get("{}/bot{}/getUpdates".format(self.tg_api_base_link,self.bot_id),timeout=5) | ||
return (True,r.content.decode("utf-8")) | ||
except Exception as ex: | ||
error+=1 | ||
print(ex) | ||
time.sleep(0.5) | ||
def sendMessage(self,chat_id,text): | ||
error=0 | ||
while True: | ||
if error>5: | ||
return(False,"Too Many Errors") | ||
try: | ||
r=requests.get("{}/bot{}/sendMessage?chat_id={}&text={}".format(self.tg_api_base_link,self.bot_id,chat_id,text),timeout=5) | ||
return r.content.decode("utf-8") | ||
except Exception as ex: | ||
error+=1 | ||
print(ex) | ||
time.sleep(0.5) |