You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple & short repository to show your bot's status in your GitHub README.md file as well as in you channel.
12
+
A simple, short, mostly customisable GitHub Action to show your bot's status in your GitHub MarkDown file as well as in your Telegram.
12
13
13
14
---
14
15
### How to use this ?
15
-
16
16
-**Star** this repo. ⭐
17
17
- Go to the repository where you want to display the status of the bots. 🤖
18
18
- Go to environment variables ([Settings ⇢ Secrets ⇢ New Repository Secret.](https://docs.github.com/en/actions/reference/encrypted-secrets)) 🚶
19
19
- Fill all Environment variables there. 🤭
20
20
- Copy [this](./example.yml) snippet in `./github/workflows/main.yml` in your repository. 📁
21
-
- The workflow will automatically run at interval of 3 hours. 🏃
22
-
23
-
_⚠️ You'll need a bots.json file and list all bots in the JSON format.
24
-
It can be raw link from `gist.github.com` or directly by the file itself like `https://github.com/<blabla>/raw/<branchname>/<filename>`. But it should point to the raw source._
21
+
- The workflow will automatically run at interval of 3 hours. 🏃
25
22
23
+
_⚠️ You'll need a valid JSON with all your bots with some additional information. Example is given in example.json, But the link shuld point to raw data like [here](https://gist.githubusercontent.com/jainamoswal/cc331a3d2a4169ab76885c5a1e076d68/raw/579dc4eabce06bc8d4e4e2192449bf1bf53a8193/bots.json). You can use [npoint.io](https://npoint.io), [gist.github.com](https://gist.github.com), [pastebin.com](https://pastebin.com), [JSONKeeper.com](https://jsonkeeper.com) etc..._
24
+
25
+
> 3rd and 4th steps are not mandatory, It's just to keep your secrets completely secret and not let anyone peep into them. You can also define them directly in `.yml` file.
|`API_HASH`| Get it from [my.telegram.org](https://my.telegram.org)|
34
-
|`APP_ID`| Get it from [my.telegram.org](https://my.telegram.org)|
35
-
|`CHANNEL_ID`| Channel ID eg. -10010254xxxxx |
36
-
|`MESSAGE_ID`| Message ID of the message to edit. |
37
-
|`SESSION`|[](https://replit.com/@jainamoswal/SessionString)|
38
-
|`BOTS`| Raw link of JSON file of bots. [example](./example.json)|
39
-
40
-
<b>Optional variables ~ </b>
41
-
-`FILE_NAME` : Name of the MarkDown file, eg. `README.md`. This is case sensitive. Defaults to `README.md`.
33
+
<b>⌲ These are mandatory variables and should be kept secret. (use [Environment variables](https://docs.github.com/en/actions/reference/encrypted-secrets))</b>
|`API_HASH`| Get it from [my.telegram.org](https://my.telegram.org)|`None`|`782xxxx`|
38
+
|`APP_ID`| Get it from [my.telegram.org](https://my.telegram.org)|`None`|`a1bbfb767fd59812bxxxxxxxxxxxxxxx`|
39
+
|`IDS`| IDs of the Messgage followed with `chat id`|`None`|`-100153418xxxx:3 -100225478xxxx:16`|
40
+
|`SESSION`|[](https://replit.com/@jainamoswal/SessionString)|`None`|`xxxxxxxxxxxxxxxx.....`|
41
+
|`BOTS`| Raw link of JSON file of bots. |[🔗 Link 🔗](https://gist.githubusercontent.com/jainamoswal/cc331a3d2a4169ab76885c5a1e076d68/raw/579dc4eabce06bc8d4e4e2192449bf1bf53a8193/bots.json)|[JSON format](/example.json) ║ [Raw link](https://gist.githubusercontent.com/jainamoswal/cc331a3d2a4169ab76885c5a1e076d68/raw/579dc4eabce06bc8d4e4e2192449bf1bf53a8193/bots.json)|
42
+
43
+
44
+
**Format of chat IDs » `chat id`:`message id`
45
+
Eg, `-100123456xxx:1x` where `100123456xxx` is `chat id` and `1x` is `message id`.**
<b>⌲ These are optional values and can be omitted. Default values will be used. (can use directly in `.yml` instead of messing Environment variables.)</b>
bots=requests.get(os.getenv('BOTS')).json() # the raw link of the gist file having config data in JSON format
17
-
api_id=os.getenv('APP_ID') # API ID from my.telegram.org
18
-
api_hash=os.getenv('API_HASH') # APP hash from my.telegram.org
19
-
session=os.getenv('SESSION') # session string via telethon
20
-
client=telethon.TelegramClient(telethon.sessions.StringSession(session), api_id, api_hash) # none of your bussiness
21
-
file_name='README.md'ifos.getenv('FILE_NAME') isNoneelseos.getenv('FILE_NAME') # filename is case sensitive
21
+
# define configs & default configs and blabla...
22
+
# Required :-
23
+
bots=requests.get(os.getenv('BOTS', 'https://bit.ly/3zzCVJE')).json() # the raw link of the gist file having config data in JSON format. Use mine incase of None provided. 😂
24
+
api_id=os.getenv('APP_ID', None) # API ID from my.telegram.org
25
+
api_hash=os.getenv('API_HASH', None) # APP hash from my.telegram.org
26
+
session=os.getenv('SESSION', None) # session string via telethon.
27
+
client=telethon.TelegramClient(telethon.sessions.StringSession(session), api_id, api_hash) # none of your business.
28
+
all_mixed_ids=os.getenv('IDS', None) # All Chat IDs along with message IDs (Telegram) to edit in format chat_id:message_id. In case of many, separate them with spaces. Eg, -100123456xxx:8x 123456xx:2xx
29
+
30
+
# Optional :-
31
+
file_name=os.getenv('FILE_NAME', 'README.md') # filename is case sensitive.
32
+
edit_in_repo=os.getenv('EDIT_IN_REPO', True) # If you want to edit status in GitHub Repo, set it to True else False.
33
+
edit_in_telegram=os.getenv('EDIT_IN_TELEGRAM', True) # If you want to edit status in Telegram, set it to True else False
34
+
start_text="Live status of my bots goes following ~"# default for start_message.
35
+
start_message=os.getenv('START_MESSAGE', start_text) # text before the status to show.
36
+
end_text="**Bots status are auto-updated every 3 hours at random frequency.**"# default for end_message.
37
+
end_message=os.getenv('END_MESSAGE', end_text) # text after the status to show.
38
+
commit_message=os.getenv('COMMIT_MESSAGE', '✨ auto-updated bot status. ✨') # commit message at status update. Btw, stars looks cool.
39
+
bullet=os.getenv('BULLET', '◪') # if you want to get custom bullets in Telegram.
40
+
time_zone=os.getenv('TIME_ZONE', 'Asia/Kolkata') # ISD. You can choose different as per your location.
41
+
time_format=os.getenv('TIME_FORMAT', '%H:%M %d/%m') # Time format, defaults to Hrs:minutes Day/Month. Eg, 9:41 12/9
42
+
current_time=datetime.now(timezone(time_zone)).strftime(time_format) # Time when the script runs.
43
+
up_github=os.getenv('UP_GITHUB', '✔️') # Custom Icon when Bot is up to show in GitHub MarkDown file.
44
+
down_github=os.getenv('DOWN_GITHUB', '❌') # Custom Icon when Bot is down to show in GitHub MarkDown file.
45
+
up_telegram=os.getenv('UP_TELEGRAM', '🚀') # Custom Icon when Bot is up to show in Telegram.
46
+
down_telegram=os.getenv('DOWN_TELEGRAM', '❌') # Custom Icon when Bot is down to show in Telegram.
22
47
23
48
# print some information
24
49
defdisplay():
25
-
print()
26
-
print(f"◻️ Telethon version : {telethon.__version__}") # telethon version
27
-
print(f"◻️ Platform : {platform.system()}") # system
28
-
print(f"◻️ Platform release : {platform.release()}") # system version
29
-
print(f"◻️ OS version : {platform.version().split()[0]}") # OS version
30
-
print()
50
+
print()
51
+
print(f"◻️ Telethon version : {telethon.__version__}") # telethon version
52
+
print(f"◻️ Platform : {platform.system()}") # system
53
+
print(f"◻️ Platform release : {platform.release()}") # system version
54
+
print(f"◻️ OS version : {platform.version().split()[0]}") # OS version
55
+
print()
56
+
57
+
# returns a list of proper formatted ids to edit in a looooooop.
text+=f"\n**Last Checked:** \n__{datetime.now(timezone('Asia/Kolkata')).strftime('%Y-%m-%d %H:%M:%S')} IST__\n\n**Bots status are auto-updated every 3 hours at random frequency.**\n\n[J Projects](https://t.me/J_Projects)"
print(f'Provided message ID ({message_id}) is invalid of chat ({chat_id}), Maybe message Id representing the Message is Deleted or was not sent before.')
107
+
exceptMessageAuthorRequiredError:
108
+
print(f'You don\'t have enough rights to edit this message.\n Chat : {chat_id} with Message {message_id}')
68
109
69
110
# run the script via __main__ style
70
111
if__name__=='__main__':
71
112
json_data=client.loop.run_until_complete(main())
72
113
display()
73
114
foreachinjson_data:
74
115
print(f"🔸 {json_data[each]['name']} [@{each}] is {'🟢'ifjson_data[each]['status'] else'🔴'}")
0 commit comments