ASP.NET Core 2.x application that receives messages via post requests and sends them to the telegram via Bot API
Startup project is TelegramBotMessageSender
Post request with message:
- Request endpoint:
http://<host>:<port>/api/Message/SendMessage
- Request body:
{channelName: "ChannelName", message:"TestMessage"}
(see Config section) - Request Header parameter
Content-Type: application/json
appsettings.json - main config and it's requeired
nlog.config - logging config and it's required too
By default it's configured to write Logs to the Console with minimum level "Info" and write all logs to the file.
More information about nlog can be found in NLog wiki
Config can be changed in real time. Changes will be applied on the next incomming message
File structure:
"telegramConfig": {
"useSocks5Proxy": true,
"botToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"channels": [
{
"channelName": "ChannelName1",
"channelId": "-000000001"
},
{
"channelName": "ChannelName2",
"channelId": "-000000002"
}
]
},
"socks5Config": {
"host": "<ip>",
"port": "<port>",
"useAuthentication": true,
"username": "admin",
"password": "password"
},
-
botToken
- telegram bot token. It's can be obtained via @BotFather.
More information: https://core.telegram.org/bots -
channels
- array ofchannelName
-channelId
mappings.channelName
- fictional "channel name" that comes with a post request and maps to the telegram channel idchannelId
- telegram group/channel id to which the bot will send messages
In order to get the telegram group/channel id:- Add the telegram Bot to the group
- Get the list of updtaes for your Bot:
https://api.telegram.org/bot<YourBOTToken>/getUpdates
. - More information: https://stackoverflow.com/questions/32423837
-
socks5Config
- just socks5 proxy settings, in case the telegram API is blocked