Changed bot "mode" behavior
This commit is contained in:
parent
5848bca40a
commit
6e1de38da0
@ -28,6 +28,7 @@ To make this bot run at first you need to have a Python interpreter and git. Goo
|
|||||||
`nano config.json`
|
`nano config.json`
|
||||||
You can edit with vim, nano, on Windows it's Notepad or Notepad++. Whatever.
|
You can edit with vim, nano, on Windows it's Notepad or Notepad++. Whatever.
|
||||||
If you don't know where to find bot_token and your id - here you can find some hints: [get bot token](https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token), [get your id](https://www.alphr.com/telegram-find-user-id/), [get api_hash and api_id](https://core.telegram.org/api/obtaining_api_id).
|
If you don't know where to find bot_token and your id - here you can find some hints: [get bot token](https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token), [get your id](https://www.alphr.com/telegram-find-user-id/), [get api_hash and api_id](https://core.telegram.org/api/obtaining_api_id).
|
||||||
|
Also don't forget to change bot's working mode. Dict key `"mode"` contains keys `"post"` and `"submit"`, each of those can be either `true` or `false`.
|
||||||
|
|
||||||
5. Add bot to the channel:
|
5. Add bot to the channel:
|
||||||
To use your bot of course you need to have a channel or group otherwise makes no sense to have such a bot. [Here](https://stackoverflow.com/a/33497769) you can find a quick guide how to add your bot to a channel.
|
To use your bot of course you need to have a channel or group otherwise makes no sense to have such a bot. [Here](https://stackoverflow.com/a/33497769) you can find a quick guide how to add your bot to a channel.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
`nano config.json`
|
`nano config.json`
|
||||||
Ви можете редагувати за допомогою vim, nano, у Windows це Notepad або Notepad++. На Ваш смак.
|
Ви можете редагувати за допомогою vim, nano, у Windows це Notepad або Notepad++. На Ваш смак.
|
||||||
Якщо Ви не знаєте, де знайти bot_token і свій ідентифікатор, тут Ви можете знайти кілька підказок: [отримати токен бота](https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token), [отримати свій ідентифікатор](https://www.alphr.com/telegram-find-user-id/), [отримати api_hash і api_id](https://core.telegram.org/api/obtaining_api_id).
|
Якщо Ви не знаєте, де знайти bot_token і свій ідентифікатор, тут Ви можете знайти кілька підказок: [отримати токен бота](https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token), [отримати свій ідентифікатор](https://www.alphr.com/telegram-find-user-id/), [отримати api_hash і api_id](https://core.telegram.org/api/obtaining_api_id).
|
||||||
|
Також не забудьте змінити режим роботи бота. Ключ `"mode"` має в собі ключі `"post"` та `"submit"`, кожен з який може бути `true` або `false`.
|
||||||
|
|
||||||
5. Додайте бота на канал:
|
5. Додайте бота на канал:
|
||||||
Звичайно, щоб використовувати свого бота, Вам потрібно мати канал або групу, інакше немає сенсу мати такого бота. [Тут](https://stackoverflow.com/a/33497769) Ви можете знайти короткий гайд, як додати свого бота до каналу.
|
Звичайно, щоб використовувати свого бота, Вам потрібно мати канал або групу, інакше немає сенсу мати такого бота. [Тут](https://stackoverflow.com/a/33497769) Ви можете знайти короткий гайд, як додати свого бота до каналу.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"module": null,
|
"module": null,
|
||||||
"mode": "both",
|
|
||||||
"locale": "en",
|
"locale": "en",
|
||||||
"locale_fallback": "en",
|
"locale_fallback": "en",
|
||||||
"admin": 0,
|
"admin": 0,
|
||||||
@ -9,6 +8,10 @@
|
|||||||
"api_hash": "",
|
"api_hash": "",
|
||||||
"bot_token": ""
|
"bot_token": ""
|
||||||
},
|
},
|
||||||
|
"mode": {
|
||||||
|
"post": true,
|
||||||
|
"submit": true
|
||||||
|
},
|
||||||
"reports": {
|
"reports": {
|
||||||
"sent": false,
|
"sent": false,
|
||||||
"error": true,
|
"error": true,
|
||||||
|
14
poster.py
14
poster.py
@ -206,13 +206,13 @@ def send_content():
|
|||||||
# Check last posts forwards
|
# Check last posts forwards
|
||||||
# check_forwards(app)
|
# check_forwards(app)
|
||||||
|
|
||||||
if configGet("mode") in ["both", "submit"]:
|
if configGet("submit", "mode"):
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["start"], prefixes="/"))
|
@app.on_message(~ filters.scheduled & filters.command(["start"], prefixes="/"))
|
||||||
def cmd_start(app, msg):
|
def cmd_start(app, msg):
|
||||||
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
||||||
msg.reply_text(locale("start", "message", locale=msg.from_user.language_code))
|
msg.reply_text(locale("start", "message", locale=msg.from_user.language_code))
|
||||||
|
|
||||||
if configGet("mode") in ["both", "submit"]:
|
if configGet("submit", "mode"):
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["rules", "help"], prefixes="/"))
|
@app.on_message(~ filters.scheduled & filters.command(["rules", "help"], prefixes="/"))
|
||||||
def cmd_rules(app, msg):
|
def cmd_rules(app, msg):
|
||||||
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
||||||
@ -263,7 +263,7 @@ def subUnblock(user):
|
|||||||
blocked.remove(user)
|
blocked.remove(user)
|
||||||
jsonSave(blocked, configGet("blocked", "locations"))
|
jsonSave(blocked, configGet("blocked", "locations"))
|
||||||
|
|
||||||
if configGet("mode") in ["both", "submit"]:
|
if configGet("submit", "mode"):
|
||||||
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
||||||
def get_submission(_, msg):
|
def get_submission(_, msg):
|
||||||
try:
|
try:
|
||||||
@ -396,7 +396,7 @@ def callback_query_unblock(app, clb): # type: ignore
|
|||||||
# # else:
|
# # else:
|
||||||
# # logWrite(f"Got raw update of type {type(update)} with contents {update}", debug=True)
|
# # logWrite(f"Got raw update of type {type(update)} with contents {update}", debug=True)
|
||||||
|
|
||||||
if configGet("mode") in ["both", "post"]:
|
if configGet("post", "mode"):
|
||||||
|
|
||||||
for entry in configGet("time", "posting"):
|
for entry in configGet("time", "posting"):
|
||||||
schedule.every().day.at(entry).do(send_content)
|
schedule.every().day.at(entry).do(send_content)
|
||||||
@ -425,11 +425,11 @@ if __name__ == "__main__":
|
|||||||
if configGet("startup", "reports"):
|
if configGet("startup", "reports"):
|
||||||
app.send_message(configGet("admin"), locale("startup", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
|
app.send_message(configGet("admin"), locale("startup", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
|
||||||
|
|
||||||
if configGet("mode") in ["both", "post"]:
|
if configGet("post", "mode"):
|
||||||
t = Thread(target=background_task)
|
t = Thread(target=background_task)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
if configGet("mode") in ["both", "submit"]:
|
if configGet("submit", "mode"):
|
||||||
# Registering user commands
|
# Registering user commands
|
||||||
for entry in os.listdir(configGet("locale", "locations")):
|
for entry in os.listdir(configGet("locale", "locations")):
|
||||||
if entry.endswith(".json"):
|
if entry.endswith(".json"):
|
||||||
@ -446,7 +446,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Registering admin commands
|
# Registering admin commands
|
||||||
commands_admin_list = []
|
commands_admin_list = []
|
||||||
if configGet("mode") in ["both", "submit"]:
|
if configGet("submit", "mode"):
|
||||||
for command in configGet("commands"):
|
for command in configGet("commands"):
|
||||||
commands_admin_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale"))))
|
commands_admin_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale"))))
|
||||||
for command in configGet("commands_admin"):
|
for command in configGet("commands_admin"):
|
||||||
|
Reference in New Issue
Block a user