Skip to content

Commit e91fc75

Browse files
committed
feat: updates, change links
1 parent 76246b0 commit e91fc75

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"[python]": {
3+
"editor.defaultFormatter": "ms-python.black-formatter"
4+
},
5+
"python.formatting.provider": "none"
6+
}

bot.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@
1717
from decouple import config
1818

1919
logging.basicConfig(
20-
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s", level=logging.INFO
20+
level=logging.INFO, format="[%(levelname)s] %(asctime)s - %(message)s"
2121
)
22+
log = logging.getLogger("ChannelAutoPost")
2223

2324
# start the bot
24-
logging.info("Starting...")
25+
log.info("Starting...")
2526
try:
2627
apiid = config("APP_ID", cast=int)
2728
apihash = config("API_HASH")
2829
bottoken = config("BOT_TOKEN")
2930
frm = config("FROM_CHANNEL", cast=lambda x: [int(_) for _ in x.split(" ")])
3031
tochnls = config("TO_CHANNEL", cast=lambda x: [int(_) for _ in x.split(" ")])
31-
datgbot = TelegramClient("bot", apiid, apihash).start(bot_token=bottoken)
32-
except:
33-
logging.error("Environment vars are missing! Kindly recheck.")
34-
logging.info("Bot is quiting...")
32+
datgbot = TelegramClient(None, apiid, apihash).start(bot_token=bottoken)
33+
except Exception as exc:
34+
log.error("Environment vars are missing! Kindly recheck.")
35+
log.info("Bot is quiting...")
36+
log.error(exc)
3537
exit()
3638

3739

@@ -41,7 +43,7 @@ async def _(event):
4143
f"Hi `{event.sender.first_name}`!\n\nI am a channel auto-post bot!! Read /help to know more!\n\nI can be used in only two channels (one user) at a time. Kindly deploy your own bot.\n\n[More bots](https://t.me/its_xditya)..",
4244
buttons=[
4345
Button.url("Repo", url="https://github.com/xditya/ChannelAutoForwarder"),
44-
Button.url("Dev", url="https://t.me/its_xditya"),
46+
Button.url("Dev", url="https://xditya.me"),
4547
],
4648
link_preview=False,
4749
)
@@ -81,12 +83,12 @@ async def _(event):
8183
else:
8284
await datgbot.send_message(tochnl, event.text, link_preview=False)
8385
except Exception as exc:
84-
logging.error(
86+
log.error(
8587
"TO_CHANNEL ID is wrong or I can't send messages there (make me admin).\nTraceback:\n%s",
8688
exc,
8789
)
8890

8991

90-
logging.info("Bot has started.")
91-
logging.info("Do visit @its_xditya..")
92+
log.info("Bot has started.")
93+
log.info("Do visit https://xditya.me !")
9294
datgbot.run_until_disconnected()

0 commit comments

Comments
 (0)