MCPcopy Create free account
hub / github.com/cppla/ServerStatus / send2tg

Function send2tg

plugin/bot-telegram.py:28–53  ·  view source on GitHub ↗
(srv, flag)

Source from the content-addressed store, hash-verified

26 print("catch exception: ", traceback.format_exc())
27
28def send2tg(srv, flag):
29 if srv not in counterOff:
30 counterOff[srv] = 0
31 if srv not in counterOn:
32 counterOn[srv] = 0
33
34 if flag == 1 : # online
35 if srv in offs:
36 if counterOn[srv] < 10:
37 counterOn[srv] += 1
38 return
39 #1. Remove srv from offs; 2. Send to tg: I am online
40 offs.remove(srv)
41 counterOn[srv] = 0
42 text = '<b>Server Status</b>' + '\n主机上线: ' + srv
43 _send(text)
44 else: #offline
45 if srv not in offs:
46 if counterOff[srv] < 10:
47 counterOff[srv] += 1
48 return
49 #1. Append srv to offs; 2. Send to tg: I am offline
50 offs.append(srv)
51 counterOff[srv] = 0
52 text = '<b>Server Status</b>' + '\n主机下线: ' + srv
53 _send(text)
54
55def sscmd(address):
56 while True:

Callers 1

sscmdFunction · 0.85

Calls 1

_sendFunction · 0.85

Tested by

no test coverage detected