├── .gitignore ├── ChangeLog ├── LICENSE ├── README.md ├── Stickers.tcl ├── Telegram-API-config.tcl ├── Telegram-API.tcl ├── lang ├── de.msg ├── en.msg └── nl.msg ├── lib ├── libhttp.tcl ├── libjson.tcl ├── libtelegram.tcl └── libunicode.tcl ├── modules ├── IRChelper.tcl ├── ImageSearch.conf ├── ImageSearch.tcl ├── Locate.conf ├── Locate.tcl ├── PSN.conf ├── PSN.tcl ├── Quotes.conf ├── Quotes.tcl ├── Soundcloud.conf ├── Soundcloud.tcl ├── Spotify.conf └── Spotify.tcl └── web └── tg.php /.gitignore: -------------------------------------------------------------------------------- 1 | .Telegram-API-config.tcl.sample 2 | .Telegram-API-config.tcl 3 | /modules/*.conf 4 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | v20190806: 2 | * Telegram-API.tcl: Addec curl version check 3 | 4 | v20190804: 5 | * Telegram-API.tcl: Added jq version check 6 | 7 | v20190803: 8 | * Telegram-API.tcl: Added more debug logging 9 | 10 | v20190801: 11 | * Telegram-API.tcl: Improved error handling on Tcl version conflict 12 | 13 | v20190731: 14 | * Telegram-API.tcl: Added Tcl version check on startup 15 | 16 | v20190325: 17 | * Telegram-API.tcl: Fixed decoding HTML entities in website title from tags 18 | 19 | v20190209: 20 | * lib/libunicode.tcl: Added Unicode 12.0 symbols 21 | 22 | v20181128: 23 | * Telegram-API.tcl: Fixed bug in function call to decodeHtmlTextEntities 24 | * Telegram-API.tcl: Added extra HTML entities 25 | 26 | v20181119: 27 | * Telegram-API.tcl: Renamed ::telegram::public_commands variable to ::telegram::tg_public_commands 28 | * Telegram-API.tcl: Renamed ::telegram::public_commands_help variable to ::telegram::tg_public_commands_help 29 | * Telegram-API.tcl: Renamed ::telegram::private_commands variable to ::telegram::tg_private_commands 30 | * Telegram-API.tcl: Renamed ::telegram::private_commands_help variable to ::telegram::tg_private_commands_help 31 | * Telegram-API.tcl: Renamed ::telegram::addPublicCommand procedure to ::telegram::addPublicTgCommand 32 | * Telegram-API.tcl: Renamed ::telegram::delPublicCommand procedure to ::telegram::delPublicTgCommand 33 | * Telegram-API.tcl: Renamed ::telegram::addPrivateCommand procedure to ::telegram::addPrivateTgCommand 34 | * Telegram-API.tcl: Renamed ::telegram::delPrivateCommand procedure to ::telegram::delPrivateTgCommand 35 | * Telegram-API.tcl: Added ::telegram::irc_public_commands variable 36 | * Telegram-API.tcl: Added ::telegram::irc_public_commands_help variable 37 | * Telegram-API.tcl: Added ::telegram::irc_private_commands variable 38 | * Telegram-API.tcl: Added ::telegram::irc_private_commands_help variable 39 | * Telegram-API.tcl: Added ::telegram::addPrivateIRCCommand procedure 40 | * Telegram-API.tcl: Added ::telegram::delPrivateIRCCommand procedure 41 | * modules/IRCHelper.tcl: Added ircChanInfo procedure 42 | * modules/IRCHelper.tcl: Added ircSetMode procedure 43 | * modules/IRCHelper.tcl: Removed ircTopic / Bugfixes 44 | * lang/de.msg: Added MSG_BOT_IRCINFO 45 | * lang/de.msg: Added MSG_BOT_IRCINFO_HELP 46 | * lang/de.msg: Added MSG_BOT_IRCSETMODE_HELP 47 | * lang/de.msg: Removed MSG_BOT_IRCTOPIC 48 | * lang/de.msg: Removed MSG_BOT_IRCTOPIC_HELP 49 | * lang/en.msg: Added MSG_BOT_IRCINFO 50 | * lang/en.msg: Added MSG_BOT_IRCINFO_HELP 51 | * lang/en.msg: Added MSG_BOT_IRCSETMODE_HELP 52 | * lang/en.msg: Removed MSG_BOT_IRCTOPIC 53 | * lang/en.msg: Removed MSG_BOT_IRCTOPIC_HELP 54 | * lang/nl.msg: Added MSG_BOT_IRCINFO 55 | * lang/nl.msg: Added MSG_BOT_IRCINFO_HELP 56 | * lang/nl.msg: Added MSG_BOT_IRCSETMODE_HELP 57 | * lang/nl.msg: Removed MSG_BOT_IRCTOPIC 58 | * lang/nl.msg: Removed MSG_BOT_IRCTOPIC_HELP 59 | 60 | v20181118: 61 | * Telegram-API.tcl: Fixed bug in ::telegram::pollTelegram for handling new_chat_member 62 | * Telegram-API.tcl: Fixed bug in ::telegram::privateCommand 63 | * Telegram-API.tcl: Renamed several chat_id variables to tg_chat_id 64 | * Telegram-API.tcl: Fixed serveraddress variable and welcome message when new Telegram users join 65 | 66 | v20181116: 67 | * Telegram-API.tcl: Fixed website descriptions on IRC 68 | * Telegram-API.tcl: Fixed #49: convert HTML entities to normal characters (ad50fc2 / bfa8e4c) 69 | * Telegram-API.tcl: Unified log message types 70 | * Telegram-API.tcl: Fixed #52: Added support for edited messages 71 | * lang/de.msg: Added MSG_TG_MSGEDITED 72 | * lang/en.msg: Added MSG_TG_MSGEDITED 73 | * lang/nl.msg: Added MSG_TG_MSGEDITED 74 | * lang/de.msg: Fixed language identifier for several messages 75 | * lang/en.msg: Fixed language identifier for several messages 76 | * lang/nl.msg: Fixed language identifier for several messages 77 | * README.md: Added troubleshooting and support 78 | 79 | v20181115: 80 | * Telegram-API.tcl: Added pre-requisites check on start-up 81 | * Telegram-API.tcl: Updated error handling on start-up when fetching bot info from the Telegram servers 82 | * libunicode.tcl: Removed 0x00a1-0x00ff from ::libunicode::escapedtable to prevent double translation of these characters; fixes # (34db2ec) 83 | 84 | v20181114: 85 | * Telegram-API.tcl: Added optional logging for debug info 86 | 87 | v20180922: 88 | * Added og:title and og:description tags for ::telegram::getWebsiteTitle (c8dc15a 82ff903 9dbe3f2) 89 | 90 | v20180919: 91 | * Fixed typo in ::telegram::ircNickChange 92 | 93 | v20180830: 94 | * Use hostmask if nick is not available on IRC modechange 95 | 96 | v20180810: 97 | * Telegram-API.tcl: Prevent showing website details on reply-to messages (e4c5f3d) 98 | 99 | v20180807: 100 | * README.md: Added description of global variables 101 | 102 | v20180803: 103 | * modules/ImageSearch.tcl: Added ::ImageSearch::getGif function 104 | 105 | v20180801: 106 | * Telegram-API.tcl: Added correct formatting of length for video/animation/audio/voice messages 107 | * lang/de.msg: Added MSG_TG_ANIMATIONSENT and modechange messages 108 | * lang/en.msg: Added MSG_TG_ANIMATIONSENT 109 | * lang/nl.msg: Added MSG_TG_ANIMATIONSENT 110 | 111 | v20180731: 112 | * Telegram-API.tcl: Added support for v4.0 (July 26, 2018) objects 113 | * modules/ImageSearch.tcl: Added error handling for api.qwant.com 114 | * modules/ImageSearch.tcl: Fixed ImageSearch due to change in Qwant API 115 | 116 | v20180730: 117 | * Telegram-API.tcl: Updated sendMessage calls to v4.0 (July 26, 2018) 118 | * modules/IRChelper.tcl: Updated sendMessage calls to v4.0 (July 26, 2018) 119 | * modules/ImageSearch.tcl: Updated sendMessage and sendPhoto calls to v4.0 (July 26, 2018) 120 | * modules/Location.tcl: Updated sendMessage and sendVenue calls to v4.0 (July 26, 2018) 121 | * modules/PSN.tcl: Updated sendMessage and sendPhoto calls to v4.0 (July 26, 2018) 122 | * modules/Quotes.tcl: Updated sendMessage calls to v4.0 (July 26, 2018) 123 | * modules/Soundcloudr.tcl: Updated sendMessage calls to v4.0 (July 26, 2018) 124 | * lib/libtelegram.tcl: Added editMessageText method 125 | * lib/libtelegram.tcl: Added editMessageCaption method 126 | * lib/libtelegram.tcl: Added editMessageMedia method 127 | * lib/libtelegram.tcl: Added editMessageReplyMarkup method 128 | * lib/libtelegram.tcl: Added deleteMessage method 129 | * lib/libtelegram.tcl: Updated sendMessage to v4.0 (July 26, 2018) 130 | * lib/libtelegram.tcl: Updated sendPhoto to v4.0 (July 26, 2018) 131 | * lib/libtelegram.tcl: Updated sendAudio to v4.0 (July 26, 2018) 132 | * lib/libtelegram.tcl: Updated sendDocument to v4.0 (July 26, 2018) 133 | * lib/libtelegram.tcl: Updated sendVideo to v4.0 (July 26, 2018) 134 | * lib/libtelegram.tcl: Updated sendVoice to v4.0 (July 26, 2018) 135 | * lib/libtelegram.tcl: Updated sendVideoNote to v4.0 (July 26, 2018) 136 | * lib/libtelegram.tcl: Updated sendLocation to v4.0 (July 26, 2018) 137 | * lib/libtelegram.tcl: Updated sendVenue to v4.0 (July 26, 2018) 138 | * lib/libtelegram.tcl: Updated sendContact to v4.0 (July 26, 2018) 139 | 140 | v20180710: 141 | * lang/en.msg: Fixed several language codes 142 | * lang/en.msg: Fixed MSG_BOT_IRCUSERS_HELP (was MSG_BOT_IRCUSER_HELP) 143 | * lang/en.msg: Added MSG_BOT_UNKNOWNCMD 144 | * lang/de.msg: Fixed several language codes 145 | * lang/en.msg: Fixed MSG_BOT_IRCUSERS_HELP (was MSG_BOT_IRCUSER_HELP) 146 | 147 | v20180613: 148 | * modules/ImageSearch.tcl: Fixed invoking ::libtelegram::sendPhoto function 149 | 150 | v20180305: 151 | * libunicode.tcl: Fixed 16-bit Unicode (BMP) translation of messages from IRC to Telegram (911abe0; thanks to TheMythPT) 152 | 153 | v20180215: 154 | * Fixed reference to non-existant variable (9770150) 155 | 156 | v20180214: 157 | * Removed old referenced to remove_slashes() 158 | * libtelegram.tcl: Added validity check to all API methods (a4b6e58) 159 | 160 | v20180213: 161 | * Added option to send a welcome message to new participants of a Telegram chat (7cd8cb9 / aaf7295 / d2a8fd6 / 85d56dd / fe19880) 162 | 163 | v20180212: 164 | * Added German translation 165 | * Added /irckick, /ircban and /ircunban commands for Telegram users 166 | * Fixed issue where a txt message starting with ? is interpreted as a bot command 167 | * Fixed an issue where changing the Telegram group picture wasn't handled correctly 168 | 169 | v20180211: 170 | * Fixed getting website title on certain websites 171 | * Moved sticker2ascii proc to Sticker.tcl 172 | * Added tg_prefer_usernames so you can choose if Telegram users are shown by their real names or by their usernames 173 | * Added localizations for all modules 174 | * Added chat title to invite link on IRC 175 | 176 | v20180210: 177 | * Fixed translation of UTF8 characters in chat title 178 | * Changed Telegram notifications to IRC channels when user joins 179 | 180 | v20180209: 181 | * libunicode.tcl: Removed redundant spaces and doublequotes (c6c2509 / 523f918) 182 | * Telegram-API.tcl: Fixed localization of private bot command help message (9062d6f) 183 | * en.msg: Fixed localization of private bot command help message (c42c102) 184 | * nl.msg: Fixed localization of private bot command help message (be85eb7) 185 | * Telegram-API.tcl: Added localization for DCC file transfers (8dee8c7) 186 | * en.msg: Added localization for DCC file transfers (3aec4ed) 187 | * nl.msg: Added localization for DCC file transfers (f0cfe39) 188 | * Fixed adding caption-texts for photo's & videos, added caption-texts for documents (91fcf89 / a4ea254 / 01a5812) 189 | * Added filesize to IRC notifications for photo attachments (67fd43a / 912e463 / ffa78ff) 190 | * Added old and new chat_id's to MSG_TG_GROUPMIGRATED (180ea1e) 191 | 192 | v20180208: 193 | * Telegram-API.tcl: ASCII emoticons from IRC are now sent to Telegram as Unicode emoji's (0be4aed) 194 | * Telegram-API.tcl: Fixed reply_to_message and forward_from messages from channels (80e95ea / eae9912) 195 | * Telegram-API.tcl: Replaced all utf2ascii calls with ::libunicode::utf82ascii (6b173bb) 196 | * Telegram-API.tcl: Removed utf2ascii and ascii2utf procedures (moved to libunicode.tcl) (28b51e2) 197 | * Telegram-API.tcl: Added verbose error handling when trying to access old chat_id's for groups which have been migrated to supergroups (f5dc9e8) 198 | * libunicode.tcl: Added more moji's and pictograms (bddbaf4 / 02e0bf0 / 710585b / f3406b4 / 0fbc7cf) 199 | * libunicode.tcl: Optimized code (75845d3) 200 | 201 | v20180207: 202 | * Telegram-API.tcl: Fixed displaying pinned messages on IRC (1c1d5c5 / cd3c75d) 203 | * libunicode.tcl: Fixed correct naming of ASCII translation tables (f952b1d / 540384f / 137134a / 12f4314) 204 | * libunicode.tcl: Fixed escaped2utf8 (5400f7b / 5acac10 / 346ec83) 205 | * libunicode.tcl: Added more emoji's and pictograms (915571d / 763f028 / b0a54d2 / 9dcb44c / cdac4c4 / cb78092 / 8546bbc / a9c501c / 2a2e0c6 / 7500945 / 0f1eed6) 206 | * en.msg: Fixed downloading attachments with !tgfile (b6a9a4c / 6d54682) 207 | * nl.msg: Fixed downloading attachments with !tgfile (95650a7) 208 | * Telegram-API.tcl: Fixed downloading attachments with !tgfile (b4b5d06) 209 | 210 | v20180202: 211 | * Telegram-API.tcl: Added support for pinned messages (5e22d32 / 6d7f897 / 9830897 / d1a1cb9 / a488d03 / 404400d / f6b8ea4) 212 | * Telegram-API.tcl: Timeout's for auto-removal of DCC-sent attachments now uses xfer-timeout (9830897) 213 | * utftable.tcl: Removed (replaced by libunicode.tcl) (c778c74) 214 | 215 | v20180201: 216 | * Telegram-API.tcl: Don't send IRC bot commands directly to the Telegram group (68059d3) 217 | * Telegram-API.tcl: Moved some code around to make the sourcecode more readable (ef43f7e) 218 | * Telegram-API.tcl: Added help messages for dynamic bot command modules (53f82fd / 2fdc271 / 32b1631 / b71c005 / 4af6152 / 215c9fc / 2d8c19a / e2583bd) 219 | 220 | v20180131: 221 | * Telegram-API.tcl: Fixed auto-removal of downloaded Telegram attachments (8886599 /6de1485) 222 | * libunicode.tcl: Moved all Unicode-related procedures and data to this file (a8d2cf9 / 9e930b2) 223 | 224 | v20180130: 225 | * Telegram-API.tcl: Userflags can now be added on a per-user base to the userfile (b654f29) 226 | * Telegram-API.tcl: Added getUserFlags (04942c8) 227 | * Telegram-API.tcl: Added downloading Telegram attachments by DCC (1664ccf / 83c4644 / 7de10b2 / 5cf4ec9 / 8f03d96 / 73df4d6) 228 | * libtelegram.tcl: Added until_date parameter to ::libtelegram::kickChatMember (9124a6e) 229 | * libtelegram.tcl: Added ::libtelegram::unbanChatMember method (9124a6e) 230 | * libtelegram.tcl: Added ::libtelegram::restrictChatMember method (9124a6e) 231 | * libtelegram.tcl: Added ::libtelegram::promoteChatMember method (9124a6e) 232 | * libtelegram.tcl: Added ::libtelegram::exportChatInviteLink method (9124a6e) 233 | * libtelegram.tcl: Added ::libtelegram::deleteChatPhoto method (9124a6e) 234 | * libtelegram.tcl: Added ::libtelegram::setChatDescription method (9124a6e) 235 | * libtelegram.tcl: Added ::libtelegram::pinChatMessage method (9124a6e) 236 | * libtelegram.tcl: Added ::libtelegram::unpinChatMessage method (9124a6e) 237 | * libtelegram.tcl: Added ::libtelegram::leaveChat method (9124a6e) 238 | * libtelegram.tcl: Added ::libtelegram::setChatStickerSet method (9124a6e) 239 | * libtelegram.tcl: Added ::libtelegram::deleteChatStickerSet method (9124a6e) 240 | 241 | v20180129: 242 | * libtelegram.tcl: Added ::libtelegram::downloadFile for downloading attachments (361b0be) 243 | 244 | v20180128: 245 | * Added channel flags for user configurable notification of topic/mode changes of IRC channels (3a977af / fe60c51) 246 | * Moved sticker definitions from utftable.tcl to Stickers.tcl (1c9c665 / 16e4524 / e5b374f) 247 | * Telegram-API.tcl: Fixed translating stickers to ASCII code (03cc7ec) 248 | * Telegram-API.tcl: Updated handling stickers (3f0d4bd) 249 | * en.msg: Updated handling stickers (dedafa2) 250 | * nl.msg: Updated handling stickers (2752840) 251 | * Telegram-API.tcl: Removed debug code from irc2tg_modeChange (336ba26) 252 | * Telegram-API.tcl: Updated colorization of nicknames to match colors in the Telegram-desktop (6845dfc) 253 | * Telegram-API-config.tcl: Updated colorization of nicknames to match colors in the Telegram-desktop (809b6c5) 254 | 255 | v20180126: 256 | * Telegram-API.tcl: Moved all config settings to the ::telegram namespace (f009e31 / e097100 / 47fade3 / d5c8dad) 257 | * Telegram-API.tcl: Added support for dynamic private bot commands (b26e9c2 / e908296) 258 | * Telegram-API.tcl: Removed ::telegram::cfg namespace (9acf807) 259 | * Telegram-API.tcl: Added logging for private bot commands (2d54a8c) 260 | * Telegram-API.tcl: Fixed recognizing public bot commands with @ (7cb9f3f / 8e176d8) 261 | * Telegram-API.tcl: Added getColorFromUserID (fa441fa) 262 | * Telegram-API.tcl: Use a user_id for calculating the color of a nick on IRC (5b983ec / a3464aa) 263 | * Telegram-API.tcl: Preliminary fix for #35 (329e50d) 264 | * Telegram-API.tcl: Fixed reproducing emoji's from quotes to Telegram (dda5fb3 / f88c966) 265 | * Telegram-API.tcl: Updated url_encode so smileys in quotes get sent correctly to Telegram (dda5fb3 / 13fe219) 266 | * Telegram-API-config.tcl: Moved all config settings to the ::telegram namespace (f009e31 / e097100) 267 | * libtelegram.tcl: Removed unused code / Fixed bug when accessing the ::telegram::tg_web_page_preview (50f37dd) 268 | * Locate.tcl: Added url in IRC response (881774d) 269 | 270 | v20180125: 271 | * Telegram-API.tcl: Added support for channels and edited messages (63d3aa0 / beb419f / ffe66b2 / 17c440e / 01c1f90 / 8a8cb31 / 154f4af / 3610e33 / a48e172 / 2c3b246) 272 | * Telegram-API.tcl: Fixed sending the caption of a photo to IRC (154f4af / 2c3b246) 273 | * Telegram-API.tcl: Fixed logging unknown messages (154f4af) 274 | * Telegram-API.tcl: Fixed an issue with tg_update_id where some messages got lost due to an invalid increase of tg_update_id (00bace0) 275 | * Telegram-API.tcl: Moved all internal variables to the ::telegram namespace (d887c77) 276 | * Telegram-API.tcl: Fixed sending IRC messages to Telegram using global user flags (493054c) 277 | 278 | v20180124: 279 | * Telegram-API.tcl: Added conditional updates from IRC to Telegram based on userflags (3fc3f4d) 280 | * Telegram-API.tcl: Added feature: user setting for command modifier (default is /) (e7b5837 / af866ac) 281 | 282 | v20180123: 283 | * ImageSearch.tcl: Added localization using msgcat (373b549 / 73bc250 / 3c064ef) 284 | * PSN.tcl: Added localization using msgcat (060d01b / e3898bc / 81641a6) 285 | * Quotes.tcl: Added localization using msgcat (0632b33 / 0d02955 / 991a8b3) 286 | * Quotes.tcl: Replaced unix-specific code with cross-platform safe code (aec3b30) 287 | * Quotes.tcl: Store new quotes with utf-8 emoji's instead of ASCII emoticons (beac70f) 288 | * Telegram-API.tcl: Replaced unix-specific code with cross-platform safe code (4e73ae8 / 2e50085) 289 | * libhttp.tcl: New library added with support for both PkgHttp and jq (2a1a0c6) 290 | 291 | v20180121: 292 | * libjson.tcl: Optimized ::libjson::hasKey jq procedure (f06952e) 293 | 294 | v20180120: 295 | * Telegram-API.tcl: Auto-load all modules in the /modules/ folder (fa68594) 296 | * Telegram-API.tcl: Added dynamic command bindings for public bot commands (370c0fc) 297 | * Telegram-API.tcl: Fixed #2 (3240d40 0c06efb 3dcce4d c004dbf 5355fbc 6d2a918 663c7df 98bebc9 47bed99 9716ecd b1e13d7 0cf7e85 01f71ed) 298 | * en.msg: Added as a replacement for Telegram-API.english.tcl 299 | * nl.msg: Added as a replacement for Telegram-API.dutch.tcl 300 | 301 | v20180119: 302 | * Telegram-API.tcl: Added support for forwarded messages (02f8af9) 303 | * Telegram-API.dutch.tcl: Added support for forwarded messages (3a14ffa) 304 | * Telegram-API.english.tcl: Added support for forwarded messages (c0bdae) 305 | * Telegram-API.tcl: Fixed issue #29 (dda5d88) 306 | * Telegram-API.tcl: Fixed issue #30 (691cc21) 307 | 308 | v20180118: 309 | * Telegram-API.tcl: Added support for migrating groups to supergroups (5e2d59e) 310 | * Telegram-API.tcl: Updated support for reply-to messages: formatting moved to language files (d5d5180) 311 | * Telegram-API.english.tcl: Added MSG_TG_MSGREPLYTOSENT and MSG_TG_GROUPMIGRATED (f566a37) 312 | * Telegram-API.dutch.tcl: Added MSG_TG_MSGREPLYTOSENT and MSG_TG_GROUPMIGRATED (08d6801) 313 | 314 | v20180117: 315 | * Telegram-API.tcl: Merged nailyk's work on using the jq JSON parser (46443c9 067078e) 316 | * Telegram-API.tcl: Updated support for reply-to messages: nicks can now be colorized 317 | * Telegram-API.tcl: Updated support for reply-to messages: reply-to is now available for all message types 318 | * libjson.tcl: Moved to jq as a json processor (66bb346) 319 | 320 | v20180117: 321 | * Telegram-API.tcl: revert support for dynamic public bot commands (moved to devel-branch) (f22eeba) 322 | * ImageSearch.tcl: Removed jq json parser code (moved to devel-branch) (fb5a10d) 323 | 324 | v20180116: 325 | * Created devel-branch for development commits 326 | 327 | v20180115: 328 | * ImageSearch.tcl: Fixed crash when server or internet connection is unavailable (9c709dd / a8fe693) 329 | * Locate.tcl: Fixed crash when server or internet connection is unavailable (e8e57e9) 330 | * PSN.tcl: Fixed crash when server or internet connection is unavailable (8a6eef2) 331 | * Soundcloud.tcl: Fixed crash when server or internet connection is unavailable (98a374b) 332 | * Spotify.tcl: Fixed crash when server or internet connection is unavailable (01a1c14) 333 | * Telegram-API.tcl: Fixed loading libraries before config file (84e8070) 334 | * libjson.tcl: Fixed namespace typo in ::libjson::internal (2f0930e) 335 | * Telegram-API.tcl: Merged first part (b879eb4) 336 | * ImageSearch.tcl: Replaced json parser with jq (a79182a) 337 | 338 | v20180114: 339 | * Renamed Telegram-API-config.tcl.sample to Telegram-API-config.tcl (63653e9 / 1fa200f) 340 | 341 | v20180113: 342 | * libtelegram.tcl: Moved bot_id and bot_token variables from Telegram-API.tcl to libtelegram.tcl 343 | * libtelegram.tcl: Fixed crashes if libtelegram can't connect to the API servers 344 | 345 | v20180111: 346 | * Telegram-API.tcl: Fixed bug in /help command in public Telegram Group 347 | * Telegram-API.tcl: Fixed correct responding to /help message 348 | * utftable.tcl: Added all country/flag Unicode codes 349 | * utftable.tcl: Added various currency Unicode characters 350 | * utftable.tcl: Added several intellectual property Unicode characters 351 | 352 | v20180105: 353 | * Telegram-API.tcl: Fixed IRC notification when a Telegram user has been added to the Telegram group 354 | * utftable.tcl: Added \ud83d\udd90 :hand_raised: 355 | 356 | v20171220: 357 | * modules/Quotes.tcl: Fixed sending quotes to Telegram with special characters [ and ] 358 | * Fixed modules/Spotify.tcl 359 | 360 | v20171219: 361 | * Added website previews for links sent from Telegram to IRC 362 | 363 | v20171218: 364 | * Updated comments in the libtelegram.tcl library 365 | * Added setWebHook, deleteWebHook and getWebHookInfo methods to the libtelegram.tcl library 366 | * Added forwardMessage method to the libtelegram.tcl library 367 | * Added sendMediaGroup, getUserProfilePhotos and getFile methods to the libtelegram.tcl library 368 | 369 | v20171217: 370 | * Added colorized nicknames on IRC (thanks go out to nailyk-fr) 371 | * Removed bold control characters from language files (thanks go out to nailyk-fr) 372 | 373 | v20171216: 374 | * Added ChangeLog (yay!) 375 | * Added login and logout to the eggdrop user database through a pm to the bot 376 | * Added myinfo for showing all information in the eggdrop user database 377 | * Replaced tg_sendReplyToMessage by tg_sendMessage (both use the same API method anyways) 378 | * Added tg_getMe method 379 | * Moved all Telegram proc's to a seperate namespace called libtelegram 380 | * Moved all Telegram proc's to a seperate tcl file called libtelegram.tcl 381 | * Added irc2tc_modeChange: support for mode changes on IRC channels 382 | * Added a PHP script called tg.php for downloading attachments from Telegram groups 383 | * Fixed an issue where emoticons in caption of a photo weren't correctly displayed 384 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2018 Eelco Huininga 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegram-API 2 | 3 | A gateway between [IRC](https://en.wikipedia.org/wiki/Internet_Relay_Chat) chat channels and [Telegram](https://telegram.org/) groups, supergroups and channels. 4 | 5 | ## Pre-requisites 6 | 7 | This script requires `tcl`, `eggdrop`, `curl` and `jq`: 8 | * [Tcl](https://www.tcl.tk/) version 8.6.x or higher - The language this script is programmed in 9 | * [Eggdrop](https://www.eggheads.org/) - The IRC bot used for connecting to your favourite IRC channels 10 | * [cURL](https://curl.haxx.se/) - Used for querying the Telegram servers 11 | * [jq](https://stedolan.github.io/jq/) version 1.5 or higher - Used for processing the JSON data 12 | 13 | ## Features 14 | 15 | * Bi-directional chats between IRC and Telegram 16 | * Support for Telegram groups, supergroups, channels and private messages 17 | * 1-to-1, 1-to-many and many-to-many linking IRC channels to Telegram groups/supergroups/channels 18 | * Seamless translation of Unicode emoji's to ASCII variants and vice-versa 19 | * Support for Telegram Stickers 20 | * Download Telegram attachments using DCC on your favourite IRC client (a PHP-script on your webserver is available as an alternative) 21 | * Multi-language support (currently English, Dutch and German are available) 22 | * Global and per-user settings for allowing/denying notifications for joins/leaves/kicks/bans etc. 23 | * You can login/logout to your Eggdrop bot from your Telegram client 24 | * Linking your Eggdrop user profile to your Telegram account 25 | * Modular support for public and private Telegram bot commands 26 | 27 | ## Quick start guide 28 | 29 | How do I setup this IRC-Telegram gateway?
30 | 1. First get an eggdrop bot up and running
31 | 2. On your Telegram client, send `/start` to @BotFather
32 | 3. Send `/newbot` to @BotFather
33 | 4. Enter the nickname of the bot you want to create
34 | 5. Enter the username of the bot you want to create
35 | 6. You'll see confirmation message like this:
36 | ``` 37 | Done! Congratulations on your new bot. You will find it at telegram.me/. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you.ve finished creating your cool bot, ping out Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this. 38 | 39 | Use this token to access the HTTP API: 40 | 123456789:AABCD-EfGhIj_KlMn_OpQrStUvWxYz12345 41 | 42 | For a description of the Bot API, see this page: https://core.telegram.org/bots/api 43 | ``` 44 | 45 |
46 | 47 | 7. Copy the `123456789` part into the Telegram-API-config.tcl script at `tg_bot_id`
48 | 8. Copy the `AABCD-EfGhIj_KlMn_OpQrStUvWxYz12345` part into the Telegram-API-config.tcl script at `tg_bot_token`
49 | 9. Add the bot to your Telegram group (don't forget the @ sign before the nickname of your bot)
50 | 10. Send a message to the group
51 | 11. Open the `https://api.telegram.org/bot123456789:AABCD-EfGhIj_KlMn_OpQrStUvWxYz12345/getUpdates` link in your webbrowser, where 123456789 is your bot id, and the AABCD-...12345 is your bottoken
52 | 12. Look up the chat_id of your chat group, and add it to the tg_channels array in Telegram-API-config.tcl script, along with the name of your IRC chat group
53 | 13. Add the Telegram-API.tcl script to your Eggdrop: 54 | ```tcl 55 | source /path/to/your/scripts/Telegram-API.tcl 56 | ``` 57 |
58 | 14. You're done! Enjoy!
59 | Please note that the only file you should modify is `Telegram-API-config.tcl`. 60 | 61 | ## Installation in Eggdrop's Docker image 62 | 63 | The standard Docker image for Eggdrop does not contain `curl` and `jq`, so you'll need to add these packages manually to the Docker image. You'll also need to do this everytime you upgrade the Docker image to the latest version. To do this, open a `bash` command prompt inside Docker and type: 64 | ``` 65 | # apk add curl jq 66 | ``` 67 | 68 | ## Upgrading to the current branch 69 | 70 | 1. Rename the `Telegram-API` folder to `Telegram-API.bak` (ALWAYS create a backup!) 71 | 2. Install the new version with `git clone https://github.com/eelcohn/Telegram-API/` 72 | 3. Compare your backed-up custom `Telegram-API-config.tcl` file with the default `Telegram-API-config.tcl` file. Take note of any settings that have been added/changed/deleted, and edit your custom config file accordingly 73 | 4. Restore your `Telegram-API-config.tcl` file from your backup folder 74 | 75 | ## Config settings 76 | 77 | `::telegram::tg_poll_freq` 78 | The poll frequency in seconds. The Telegram-API script uses a polling technique for fetching status updates from the Telegram servers. This variable determines the wait period between each status update poll. 79 | 80 | `::telegram::tg_web_page_preview` 81 | Disables link previews for links in messages sent to the Telegram groups/channels. See https://core.telegram.org/bots/api for more information. 82 | 83 | `::telegram::tg_prefer_usernames` 84 | If this variable is set to true, the Telegram username will be used when a message is sent from the Telegram group to an IRC channel. If set to false, the Telegram first and last name will be used. 85 | 86 | `::telegram::locale` 87 | The locale used for translating messages. Language files (used by `::telegram::locale`) can be found in the `lang` folder. 88 | 89 | `::telegram::timeformat` 90 | This variable is used for formatting dates and times. See https://www.tcl.tk/man/tcl8.5/tutorial/Tcl41.html for valid settings. 91 | 92 | `::telegram::colorize_nicknames` 93 | If this variable is set, colors are added to the Telegram nicknames when a message is sent from a Telegram group to an IRC channel. The color is calculated by taking the modulus of the Telegram user ID and the `::telegram::colorize_nicknames` variable. Valid setting is between 1 and 15. 94 | 95 | `::telegram::userflags` 96 | 97 | | Flag | Description | 98 | |------|-------------| 99 | | c | nick_change: If this flag is set, a nick changed message is sent to the Telegram group if the specified user changes it's nickname | 100 | | j | join: If this flag is set, a join message is sent to the Telegram group if the specified user joins the IRC channel | 101 | | k | kick: If this flag is set, a kick message is sent to the Telegram group if the specified user is kicked from the IRC channel | 102 | | l | leave: If this flag is set, a leave message is sent to the Telegram group if the specified user leaves the IRC channel | 103 | | m | mode_change: If this flag is set, a message is sent to the Telegram group if the IRC mode for the specified user is changed | 104 | | v | voice: If this flag is set, messages by the specified user are sent to the Telegram group | 105 | 106 | `::telegram::chanflags` 107 | 108 | | Flag | Description | 109 | |------|-------------| 110 | | i | invite: If this flag is set, a message with an invite link to the Telegram group will be sent to the IRC channel if an user joins the IRC channel | 111 | | m | mode_change: If this flag is set, a message is sent to the Telegram group if the IRC mode of the IRC channel is changed | 112 | | p | pinned: If this flag is set, pinned messages in the Telegram group will be sent to the IRC channel if an user joins the IRC channel | 113 | | s | set_topic: If this flag is set, and the topic of the IRC channel is changed, the topic of the Telegram group is set to the new topic of the IRC channel | 114 | | t | topic: If this flag is set, and the topic of the IRC channel is changed, a message will be sent to the Telegram group | 115 | | w | welcome_pub: If this flag is set, a public message will be sent to the Telegram group if an user joins the Telegram group | 116 | | W | welcome_prv: If this flag is set, a private message will be sent to the user if the user joins the Telegram group | 117 | 118 | `::telegram::cmdmodifier` 119 | All Telegram messages starting with any character in the `::telegram::cmdmodifier` variable is interpreted as an bot-command. 120 | 121 | ## File descriptions 122 | 123 | | File | Description | 124 | |------------------------------------------------------------------|---------| 125 | | `Telegram-API-config.tcl` | All user configurable settings are set in this file. Rename to Telegram-API-config.tcl and edit according to your preferences before use. | 126 | | `Telegram-API.tcl` | Main code. Include this file in your `eggdrop.conf` file. | 127 | | `utftable.tcl` | Translation from UTF characters and emoticons to ASCII characters and emoticons. | 128 | | `lang/Telegram-API.*.tcl` | All language dependant strings are defined here. For example, if you want to change the way Telegram messages are sent towards the IRC channel, you can define it here. | 129 | | `lib/libjson.tcl` | Generic JSON library for Tcl. All generic JSON functions are defined here. | 130 | | `lib/libtelegram.tcl` | Generic Telegram library for Tcl. All functions which call the Telegram API methods are defined here. See https://core.telegram.org/bots/api#available-methods for a list of all available Telegram API methods. | 131 | | `lib/libunicode.tcl` | Generic Unicode library for Tcl. All generic functions for translating between UTF-8/UTF-16/Escaped Unicode/ASCII characters are defined here. | 132 | | `modules/*.tcl` | All publically available Telegram bot commands are defined here. Optional, not needed for basic operation. | 133 | | `web/tg.php` | PHP script which allow IRC users to download images, video's and other attachments posted in the Telegram group. | 134 | 135 | ## Troubleshooting 136 | 137 | ##### `libtelegram::initialize: curl not found. Please install curl before starting the Telegram API script.` 138 | You haven't installed `curl` or the script cannot find/start `curl` for some reason. (Re)install `curl` and try again. 139 | 140 | ##### `libtelegram::initialize: jq not found. Please install jq before starting the Telegram API script.` 141 | You haven't installed `jq` or the script cannot find/start `jq` for some reason. (Re)install `jq` and try again. 142 | 143 | ##### `libtelegram::initialize: Unable to get bot info from Telegram (401 - Not authorized)` 144 | You have set an incorrect bot id and/or bot token in the `Telegram-API-config.tcl` file, and the script cannot log into the Telegram servers. Please check the bot id and token and try again. 145 | 146 | ##### `"telegram::pollTelegram: The group with id 12345 has been migrated to a supergroup by lamer. Please edit your config file and add 67890" 147 | The Telegram user called lamer migrated the group to a supergroup. Replace the chat_id in your Telegram-API-config.tcl file. 148 | 149 | ##### `telegram::pollTelegram: Please edit your conf file with your new chat_id: 123456789` 150 | One of the groups in your `Telegram-API-config.tcl` file has been migrated (by you?) to a supergroup or channel. Please change it to the new chat_id. 151 | 152 | ##### `telegram::getUpdates: 429 - Too Many Request: retry after x` 153 | The Telegram servers complain that the poll frequency for your bot is set too low, and you're sending too many update requests. Increase the `::telegram::tg_poll_freq` setting in your config file by a couple of seconds. 154 | 155 | ##### `telegram::pollTelegram: Unknown message received: abcxyz` 156 | This should not happen. Please report this error by opening an issue. 157 | 158 | ##### `bad option "decode": must be format or scan` 159 | You're probably running an older version of Tcl. Please update Tcl to the latest version. 160 | 161 | ## Support 162 | 163 | You can try to get support on the `#telegram-api` channel on `irc.freenode.net` 164 | 165 | ## Feedback 166 | 167 | Please let me know if you use this script, if you run into bugs or problems, and of course if you like it! Or you can buy me a cup of coffee ;-) 168 | 169 | [![paypal](https://www.paypalobjects.com/en_US/NL/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UEE477V44JWKY) 170 | -------------------------------------------------------------------------------- /Stickers.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API Sticker module for Eggdrop v20181214 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Replace sticker code with ASCII code # 9 | # ---------------------------------------------------------------------------- # 10 | proc sticker2ascii {file_id} { 11 | global stickertable 12 | 13 | foreach {filedesc stickerdesc} [array get stickertable] { 14 | if {$file_id == $filedesc} { 15 | return $stickerdesc 16 | } 17 | } 18 | 19 | return [::msgcat::mc MSG_TG_UNKNOWNSTICKER] 20 | } 21 | 22 | # ---------------------------------------------------------------------------- # 23 | # Sticker set definitions # 24 | # ---------------------------------------------------------------------------- # 25 | 26 | array set stickersets { 27 | {TelegramGreatMinds} {"Great Minds"} 28 | {EvilMinds} {"Evil Minds"} 29 | } 30 | 31 | array set stickertable { 32 | # Great minds stickerset 33 | {CAADBAADGQADyIsGAAFl6KYZBflVyQI} {"Abraham Lincoln - https://telegram.org/file/811140066/1/7fM-CwKk4F0/53f9f1fc731c63547d"} 34 | {CAADBAADIQADyIsGAAHaCFln7THl9QI} {"Albert Einstein - https://telegram.org/file/811140981/1/9ypk7z_8T4Q/4381a7a74256fe0b9b"} 35 | {CAADBAADOAADyIsGAAE7re09I3hMQwI} {"Arthur C. Doyle - "} 36 | {CAADBAADKQADyIsGAAEPYMQ7iT8jRgI} {"Audrey Hepburn - https://telegram.org/file/811140508/1/0BiCdZ28uVw/ca64f37939b1bdea11"} 37 | {CAADBAADPAADyIsGAAHP7udlFGeCVgI} {"Benjamin Franklin - "} 38 | {CAADBAADJQADyIsGAAGoEDksgR1WpAI} {"Bob Marley - https://telegram.org/file/811140235/2/_ZthaAI89Ds/4a2f85c6feac9e1bca"} 39 | {CAADBAADPQADyIsGAAER4mZIkRHRsgI} {"Bruce Lee - "} 40 | {CAADBAADHQADyIsGAAFsLeimr-HBPAI} {"Charlie Chaplin - https://telegram.org/file/811140437/2/VdpCps5zB1o/c906dac5e81170dc74"} 41 | {CAADBAADQwADyIsGAAHtlVE1rDyZXQI} {"Che Guevaris - "} 42 | {CAADBAADJAADyIsGAAGbgy1wIY571wI} {"Cleopatra - https://telegram.org/file/811140617/2/JdFfZi4Ruhk/3444e8ea6e1a88ace4"} 43 | {CAADBAADKAADyIsGAAHTcQFJMaFa0QI} {"Coco Chanel - https://telegram.org/file/811140860/1/_sVhXePrr-I/02a6e44c917d7c7f6f"} 44 | {CAADBAADMAADyIsGAAEq-fQsNrRXjAI} {"Dante Alighieri - https://telegram.org/file/811140444/1/NqWMRLWzg1U/623bd278ff0179ded9"} 45 | {CAADBAADIwADyIsGAAHeuQrNOU12cgI} {"Edgar Allan Poe - https://telegram.org/file/811140654/1/xFdm58wPNH4/191814f44f5d36f9a4"} 46 | {CAADBAADNgADyIsGAAFUgH2PcO7e6QI} {"Edvard Munch - "} 47 | {CAADBAADPwADyIsGAAGI1S2AmQ002AI} {"Elvis Presley - "} 48 | {CAADBAADNwADyIsGAAFOgk-EJUfH-gI} {"Ervin Shryodinger - "} 49 | {CAADBAADFgADyIsGAAGo-jfilnNJyAI} {"Franz Kafka - https://telegram.org/file/811140332/2/KJzzslK440U/b11181fd7bbf1c56aa"} 50 | {CAADBAADQAADyIsGAAE7MpzFPFQX5QI} {"Freddy Mercury - "} 51 | {CAADBAADMgADyIsGAAGw4osRBXRB3AI} {"Frederik Douglas - https://telegram.org/file/811140519/1/8vLtx2w3n10/2a603572363d422fc0"} 52 | {CAADBAADMwADyIsGAAFI6xgyK-qNMgI} {"George Carlin - "} 53 | {CAADBAADRQADyIsGAAH1EiOQIkWtagI} {"George Orwell - "} 54 | {CAADBAADNAADyIsGAAGjDT0cxHKm2gI} {"George Washington - "} 55 | {CAADBAADOQADyIsGAAG3aA9Q2a6wywI} {"Howard Lavkraft - "} 56 | {CAADBAADRAADyIsGAAFtStkoP5sgQQI} {"Isaac Newton - "} 57 | {CAADBAADLQADyIsGAAGJcalkB0bXSQI} {"Jay Hawkins - https://telegram.org/file/811140885/1/r4SVbb90Quc/7333932a5fdcf5f057"} 58 | {CAADBAADLgADyIsGAAGPsGcNmlLjPQI} {"Jimi Hendrix - https://telegram.org/file/811140525/2/vCDL8Gv_k6U/a39c95e5aa621c46c6"} 59 | {CAADBAADOgADyIsGAAH3hdtO3aqUpwI} {"Jeanne d'Arc - "} 60 | {CAADBAADGAADyIsGAAGsLFQJpxof0QI} {"John Lennon - https://telegram.org/file/811140517/1/yDccYORy60c/da6c69de6ad5afcb8f"} 61 | {CAADBAADFAADyIsGAAFXtQ3Z4ZqdLAI} {"J.R.R. Tolkien - https://telegram.org/file/811140679/1/qyTW5F98KLA/ed2db7cc24b8938e07"} 62 | {CAADBAADEgADyIsGAAE-gRk5Wrs8NwI} {"Julius Cesar approves - https://telegram.org/file/811140007/2/uHbXgsdVXQY/a75eee858dd829fb89"} 63 | {CAADBAADIAADyIsGAAGwI-I5pMSEdQI} {"Julius Cesar disapproves - https://telegram.org/file/811140801/1/14Ka_5LSkus/11ef924b87783bd339"} 64 | {CAADBAADPgADyIsGAAEuCrQ7AXgedwI} {"Kurt Cobain - "} 65 | {CAADBAADRgADyIsGAAF-kAhqVu7-1QI} {"Leopold von Sacher-Masoch - "} 66 | {CAADBAADQQADyIsGAAHv8OkTOGk0SwI} {"Louis Armstrong - "} 67 | {CAADBAADGwADyIsGAAE68wt0DU90mgI} {"Mahatma Gandhi - https://telegram.org/file/811140053/1/A6JVcXDZiZM/d28d4a5029d010e953"} 68 | {CAADBAADLwADyIsGAAHjj-PTeuEdBgI} {"Malcom X - https://telegram.org/file/811140689/2/VQ95ysNb35U/4adabae15888ee9b37"} 69 | {CAADBAADEAADyIsGAAFCZre3kULkngI} {"Marilyn Monroe - https://telegram.org/file/811140117/2/dGMVFePbDos/68ae9b4e90b10c1fb8"} 70 | {CAADBAADHwADyIsGAAFHId3ggt-PAAEC} {"Mark Twain - https://telegram.org/file/811140849/1/cpP6i93xxaA/c082e8a2ad59522cfd"} 71 | {CAADBAADMQADyIsGAAEX-8KrVIT5lwI} {"Napoleon Bonaparte - https://telegram.org/file/811140354/1/-NUBye754Pw/2fa1e3148047b624b3"} 72 | {CAADBAADFQADyIsGAAHPdbDyCcpB8gI} {"Nikola Tesla - "} 73 | {CAADBAADLAADyIsGAAF6cRm5hiOkCAI} {"Princess Diana - https://telegram.org/file/811140066/2/mv4D4qzDys8/d19275c7c681c63367"} 74 | {CAADBAADEwADyIsGAAHgGKfPXeaQDAI} {"Richard Wagner - https://telegram.org/file/811140446/1/ZOVGuV17wSI/932a093624e7bec4c9"} 75 | {CAADBAADHAADyIsGAAFzjQavel2uswI} {"Salvador Dali - https://telegram.org/file/811140579/1/i974MzakdcM/7752f8ee0262a57fdd"} 76 | {CAADBAADGgADyIsGAAHw_WAnR5mwUAI} {"Siegmund Freud - https://telegram.org/file/811140811/2/FJWJRL9vxME/b44ed832aced2e6dc7"} 77 | {CAADBAADFwADyIsGAAF1CK9t7qjAigI} {"Steve Jobs - https://telegram.org/file/811140823/2/gEXq-ZISs9g/55f6c9c9f87c4dceb0"} 78 | {CAADBAADJwADyIsGAAH6wu4EMqyrvgI} {"Virginia Vulf - https://telegram.org/file/811140251/1/kjMKzKP2S6o/16635fe8e0485bd0b8"} 79 | {CAADBAADNQADyIsGAAF_Q3DFvKDCzgI} {"Walt Disney - "} 80 | {CAADBAADQgADyIsGAAHbkbbtFVHNZAI} {"Whitney Houston - "} 81 | {CAADBAADOwADyIsGAAFClAdwTFmgJwI} {"Wilhelm Konrad Rontgen - "} 82 | {CAADBAADRwADyIsGAAGQU-a9UvB-xQI} {"William Shakespear - "} 83 | 84 | # Evil minds stickerset 85 | {CAADAgADhQMAAgi3GQJJ-luqZysfcQI} {"Adolf Hitler"} 86 | {CAADAgADDAQAAgi3GQLZhDzBxoQ47gI} {"Albert de Gondi"} 87 | {CAADAgADDwQAAgi3GQKn6x4arMBASgI} {"Albert Fish"} 88 | {CAADAgADLwQAAgi3GQIqOMZ-BTCsXAI} {"Aleister Crowley"} 89 | {CAADAgADIQQAAgi3GQJm4nUGNLXssAI} {"Anton LaVey"} 90 | {CAADAgAD6wcAAgi3GQLh6oKAnDyHSAI} {"Augusto Pinochet"} 91 | {CAADAgADgwMAAgi3GQJR9yC4FrbWZAI} {"Benito Mussolini"} 92 | {CAADAgADlgMAAgi3GQL1c5fysxo50QI} {"Caligula"} 93 | {CAADAgADEgQAAgi3GQKgpTqoAoh63AI} {"Elisabeth Bathory"} 94 | {CAADAgADgQMAAgi3GQIiG0lIV05f5AI} {"Grigori Rasputin"} 95 | {CAADAgADiQMAAgi3GQJ7vTUBG994kQI} {"Heinrich Himmler"} 96 | {CAADAgADHQQAAgi3GQLlWmBAyRLdAAEC} {"Herod the Great"} 97 | {CAADAgADjQMAAgi3GQLa8GKrKtcI8wI} {"Idi Amin Dada"} 98 | {CAADAgADhwMAAgi3GQJaBKaj3TGUPAI} {"Ioseb Goebbels"} 99 | {CAADAgADkwMAAgi3GQIl7uGVipqu-QI} {"Ivan the Terrible"} 100 | {CAADAgADHwQAAgi3GQID7ia8R0aqJgI} {"Jim Jones"} 101 | {CAADAgADLQQAAgi3GQJ-iD6c-tUyxwI} {"John Wilks Booth"} 102 | {CAADAgADiwMAAgi3GQJbJJ5TL4zWFAI} {"Joseph Stalin"} 103 | {CAADAgADdQMAAgi3GQJVu8dRhRDFhwI} {"Judas Iscariot"} 104 | {CAADAgADMQQAAgi3GQI12tfK6nbikQI} {"Mao Zedong"} 105 | {CAADAgADKQQAAgi3GQJ45o2-bRDUZwI} {"Nero Germanicus"} 106 | {CAADAgADkQMAAgi3GQJnw6KGbwNtmwI} {"Osama Bin Laden"} 107 | {CAADAgADGwQAAgi3GQIAARgrCY1-Kg8C} {"Pablo Escobar"} 108 | {CAADAgADKwQAAgi3GQJIDzoO-7w0jAI} {"Pol Pot"} 109 | {CAADAgADfwMAAgi3GQImCrotVl2jpQI} {"Pope Alexander VI"} 110 | {CAADAgADjwMAAgi3GQLeZcznLRZS9QI} {"Saddam Hussein"} 111 | {CAADAgADfQMAAgi3GQLJsHVGG7QJ2gI} {"Tomas de Torquemada"} 112 | {CAADAgADJQQAAgi3GQKS4b910iYMrgI} {"Victor Lustig"} 113 | {CAADAgADeQMAAgi3GQIE0j5N4LIhQQI} {"Vlad the Impaler"} 114 | {CAADAgADIwQAAgi3GQIp7k4OQeIooQI} {"Vladimir Lenin"} 115 | } 116 | -------------------------------------------------------------------------------- /Telegram-API-config.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API configuration v20181118 for Eggdrop # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | set ::libtelegram::bot_id 123456789 11 | set ::libtelegram::bot_token AABCD-EfGhIj_KlMn_OpQrStUvWxYz12345 12 | set ::telegram::tg_poll_freq 5 13 | set ::telegram::tg_web_page_preview false 14 | set ::telegram::tg_prefer_usernames true 15 | set ::telegram::locale "en" 16 | set ::telegram::timeformat "%Y-%m-%d %H:%M:%S" 17 | set ::telegram::colorize_nicknames 7 18 | set ::telegram::userflags "jlvckm" 19 | set ::telegram::chanflags "iptms" 20 | set ::telegram::cmdmodifier "/!." 21 | array set ::telegram::usercolors { 0 4 22 | 1 7 23 | 2 6 24 | 3 3 25 | 4 10 26 | 5 2 27 | 6 13} 28 | array set ::telegram::tg_channels { 29 | "-21436587" "#lamer" 30 | "-171615141" "#lamer-test" 31 | } 32 | -------------------------------------------------------------------------------- /lang/de.msg: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API module for Eggdrop - German language file v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # Messages from IRC to Telegram 8 | ::msgcat::mcset de MSG_IRC_MSGSENT "%1\$s@IRC: %2\$s" 9 | ::msgcat::mcset de MSG_IRC_NICKJOINED "%1\$s@IRC ist %3\$s hereingekommen." 10 | ::msgcat::mcset de MSG_IRC_NICKLEFT "%1\$s@IRC hat %3\$s (%4\$s) verlassen." 11 | ::msgcat::mcset de MSG_IRC_NICKACTION "%1\$s@IRC: %2\$s %3\$s" 12 | ::msgcat::mcset de MSG_IRC_NICKCHANGE "%1\$s@IRC ist jetzt bekannt als %2\$s" 13 | ::msgcat::mcset de MSG_IRC_TOPICCHANGE "%1\$s@IRC hat das Thema auf %3\$s in %4\$s geändert." 14 | ::msgcat::mcset de MSG_IRC_KICK "%1\$s@IRC hat %2\$s von %3\$s getreten: %4\$s" 15 | ::msgcat::mcset de MSG_IRC_SETCHANMODE "%1\$s@IRC sets the channel mode %2\$s on %3\$s" 16 | ::msgcat::mcset de MSG_IRC_REMCHANMODE "%1\$s@IRC removes the channel mode %2\$s from %3\$s" 17 | ::msgcat::mcset de MSG_IRC_SETUSERMODE "%1\$s@IRC gives %2\$s to %3\$s on %4\$s" 18 | ::msgcat::mcset de MSG_IRC_REMUSERMODE "%1\$s@IRC takes %2\$s from %3\$s on %4\$s" 19 | 20 | # IRC service messages 21 | ::msgcat::mcset de MSG_IRC_INVITELINK "Schließe dich der Telegramm%1\$s %2\$s hier %3\$s an." 22 | ::msgcat::mcset de MSG_IRC_DCCSENDFAILED "Datei konnte nicht gesendet werden. Kontakt den Administrator, sich die Protokolldatei anzusehen." 23 | ::msgcat::mcset de MSG_IRC_DCCSENDFILE "Start DCC Übertragung %1\$s." 24 | ::msgcat::mcset de MSG_IRC_DCCSENDFULL "Kann %1\$s nicht senden (zu viele DCC Verbindungen). Bitte versuche es später noch einmal." 25 | ::msgcat::mcset de MSG_IRC_DCCSOCKET "Kann keinen Socket für die Übertragung von %1\$s öffnen." 26 | ::msgcat::mcset de MSG_IRC_DCCNOTFOUND "Datei %1\$s nicht gefunden." 27 | ::msgcat::mcset de MSG_IRC_DCCQUEUED "Die Datei %1\$s wird zur Übertragung in die Warteschlange gestellt." 28 | 29 | # Messages from Telegram to IRC 30 | ::msgcat::mcset de MSG_TG_MSGSENT "%1\$s@Telegram: %2\$s" 31 | ::msgcat::mcset de MSG_TG_MSGREPLYTOSENT "%1\$s (als Antwort auf %2\$s@Telegram: %3\$s)" 32 | ::msgcat::mcset de MSG_TG_MSGFORWARDED "%1\$s (weitergeleitet von %2\$s)" 33 | ::msgcat::mcset de MSG_TG_MSGEDITED "%1\$s (Nachricht von %2\$s wurde am %3\$s geändert)" 34 | ::msgcat::mcset de MSG_TG_PINNEDMESSAGE "%1\$s@Telegram: %2\$s (festgesteckt auf %3\$s)" 35 | ::msgcat::mcset de MSG_TG_AUDIOSENT "%1\$s@Telegram hat eine Audiodatei gesendet: %2\$s - %3\$s (%4\$s s). Du kannst es mit !tgfile %5\$s herunterladen." 36 | ::msgcat::mcset de MSG_TG_ANIMATIONSENT "%1\$s@Telegram hat eine Animation gesendet%2\$s (%3\$s s). Du kannst es mit !tgfile %4\$s herunterladen." 37 | ::msgcat::mcset de MSG_TG_DOCSENT "%1\$s@Telegram hat ein Dokument gesendet%2\$s: %3\$s (%4\$s bytes). Du kannst es mit !tgfile %5\$s herunterladen." 38 | ::msgcat::mcset de MSG_TG_PHOTOSENT "%1\$s@Telegram hat ein Foto gesendet%2\$s (%3\$s bytes). Du kannst es mit !tgfile %4\$s herunterladen." 39 | ::msgcat::mcset de MSG_TG_STICKERSENT "%1\$s@Telegram hat einen Aufkleber aus dem Set %2\$s geschickt (%3\$s)." 40 | ::msgcat::mcset de MSG_TG_VIDEOSENT "%1\$s@Telegram hat ein Video gesendet%2\$s (%3\$s s). Du kannst es mit !tgfile %4\$s herunterladen." 41 | ::msgcat::mcset de MSG_TG_VOICESENT "%1\$s@Telegram hat eine Sprachdatei gesendet: %2\$s (%3\$s bytes). Sie können es mit !tgfile %4\$s herunterladen." 42 | ::msgcat::mcset de MSG_TG_CONTACTSENT "%1\$s@Telegram hat einen Kontakt gesendet: %2\$s (%3\$s %4\$s)." 43 | ::msgcat::mcset de MSG_TG_LOCATIONSENT "%1\$s@Telegram hat einen Standort gesendet: https://www.openstreetmap.org/#map=19/%3\$s/%2\$s" 44 | ::msgcat::mcset de MSG_TG_VENUESENT "%1\$s@Telegram hat einen Veranstaltungsort geschickt: Standort=%2\$s Titel=%3\$s Adresse=%4\$s foursquare_id=%5\$s." 45 | ::msgcat::mcset de MSG_TG_WELCOME "Wilkommen bei %1\$s! Ich bin %2\$s, dein Barkeeper in dieser Telegram gruppe. Ich bin mit dem IRC-Kanal %4\$s verbunden, so dass du auch mit den Benutzern auf diesem Kanal sprechen kannst." 46 | ::msgcat::mcset de MSG_TG_USERJOINED "%1\$s@Telegram hat sich der Telegram-Gruppe angeschlossen." 47 | ::msgcat::mcset de MSG_TG_USERADD "%1\$s@Telegram hat %2\$s zur Telegrammgruppe hinzugefügt." 48 | ::msgcat::mcset de MSG_TG_USERLEFT "%1\$s@Telegram hat die Telegrammgruppe verlassen." 49 | ::msgcat::mcset de MSG_TG_USERREMOVED "%1\$s@Telegram hat %2\$s aus der Telegrammgruppe entfernt." 50 | ::msgcat::mcset de MSG_TG_TITLECHANGE "%1\$s@Telegram hat das Thema auf die Telegramgruppe in %2\$s geändert." 51 | ::msgcat::mcset de MSG_TG_PICCHANGE "%1\$s@Telegram hat das Telegramm Gruppenbild geändert. Du kannst es mit !tgfile %2\$s herunterladen." 52 | ::msgcat::mcset de MSG_TG_PICDELETE "%1\$s@Telegram has removed the Telegram group picture." 53 | ::msgcat::mcset de MSG_TG_GROUPMIGRATED "%1$\s@Telegram hat das Telegramm Gruppenbild entfernt." 54 | ::msgcat::mcset de MSG_TG_CHATTITLE "%1\$s ist ein %2\$s und trägt den Titel %3\$s" 55 | ::msgcat::mcset de MSG_TG_CHATDESC "%1\$s hat eine Beschreibung: %2\$s" 56 | ::msgcat::mcset de MSG_TG_CHATMEMBERCOUNT "%1\$s hat %2\$s Mitglieder" 57 | ::msgcat::mcset de MSG_TG_CHATPHOTO "%1\$s hat ein Gruppenbild: !tgfile %2\$s" 58 | ::msgcat::mcset de MSG_TG_UNKNOWNSTICKER "Unbekannter Aufkleber." 59 | ::msgcat::mcset de MSG_TG_UNIMPL "Unbekannte Telegrammnachricht empfangen: %1\$s" 60 | ::msgcat::mcset de MSG_WEBPREVIEW_UNAVAILABLE "Vorschau nicht verfügbar." 61 | ::msgcat::mcset de MSG_WEBPREVIEW_NOTITLE "Kein titel verfügbar." 62 | 63 | # Messages for user commands for your bot 64 | ::msgcat::mcset de MSG_BOT_PUBHELP "Ich bin %1\$s, dein persönlicher Barkeeper. Verfügbare Befehle sind:\n" 65 | ::msgcat::mcset de MSG_BOT_PRVHELP "Ich bin %1\$s, dein persönlicher Barkeeper. Verfügbare Befehle sind:\n" 66 | ::msgcat::mcset de MSG_BOT_HELP_IRCUSER "Sie haben keinen Benutzernamen eingegeben. Type /ircuser to look up information on an IRC user." 67 | ::msgcat::mcset de MSG_BOT_IRCINFO "Das Thema auf die Telegramgruppe %2\$s ist: %3\$sDer Kanalmodus ist auf %3\$s eingestellt." 68 | ::msgcat::mcset de MSG_BOT_IRCINFO_HELP ": Zeigen Sie Information für die IRC-Kanäle an, die mit dieser Telegrammgruppe verbunden sind." 69 | ::msgcat::mcset de MSG_BOT_IRCUSERS "Die folgenden Benutzer sind auf %2\$s\ bekannt:\n\n%3\$s" 70 | ::msgcat::mcset de MSG_BOT_IRCUSERS_HELP ": Zeigen Sie alle Benutzer auf den IRC-Kanälen an, die mit dieser Telegrammgruppe verbunden sind." 71 | ::msgcat::mcset de MSG_BOT_IRCUSER "%1\$s@IRC ist seit dem %2\$s auf %4\$s als %5\$s bekannt." 72 | ::msgcat::mcset de MSG_BOT_IRCUSERUNKNOWN "%1\$s@IRC ist nicht bekannt auf %3\$s" 73 | ::msgcat::mcset de MSG_BOT_IRCUSER_HELP " : Zeigen Sie detaillierte Informationen zu einem IRC-Benutzer an." 74 | ::msgcat::mcset de MSG_BOT_IRCKICKUSER "Sie wurden von einem Telegram-Benutzer aus diesem Kanal geworfen." 75 | ::msgcat::mcset de MSG_BOT_IRCBANUSER "Du wurdest von einem Telegram-Benutzer von diesem Kanal ausgeschlossen." 76 | ::msgcat::mcset de MSG_BOT_IRCKICK_HELP " : Tritt ein IRC-Benutzer aus dem IRC-Kanal." 77 | ::msgcat::mcset de MSG_BOT_IRCBAN_HELP " : Verbanne einen IRC-Benutzer vom IRC-Kanal." 78 | ::msgcat::mcset de MSG_BOT_IRCUNBAN_HELP " : Entarre einen IRC-Benutzer vom IRC-Kanal." 79 | ::msgcat::mcset de MSG_BOT_IRCSETMODE_HELP " : Stellen Sie den Kanalmodus für diesen Kanal ein." 80 | ::msgcat::mcset de MSG_BOT_TGWHOISNAME "Telegram ID %1\$s ist %2\$s und ist bekannt als %3\$s%4\$s." 81 | ::msgcat::mcset de MSG_BOT_TGWHOISSTATUS "Telegram ID %1\$s hat status %2\$s." 82 | ::msgcat::mcset de MSG_BOT_TGWHOISLANG "Telegram ID %1\$s hat ein Sprachcode von %2\$s." 83 | ::msgcat::mcset de MSG_BOT_TGWHOISPHOTO "Telegram ID %1\$s hat ein Benutzerfoto eingestellt: !tgfile %2\$s" 84 | ::msgcat::mcset de MSG_BOT_USERNOTVALID "Informationen zu Telegram ID %1\$s auf diesem Kanal können nicht abgerufen werden." 85 | ::msgcat::mcset de MSG_BOT_TGUSER "ein Benutzer" 86 | ::msgcat::mcset de MSG_BOT_TGBOT "ein bot" 87 | ::msgcat::mcset de MSG_BOT_UNKNOWNCMD "Ich verstehe das nicht. Geben Sie /help ein, um eine Liste aller Befehle anzuzeigen." 88 | ::msgcat::mcset de MSG_BOT_GOTNOPRIVS "%1\$s ist dazu nicht berechtigt." 89 | 90 | # Messages for admins controlling your bot 91 | ::msgcat::mcset de MSG_BOT_PASSWORDSET "Willkommen bei %1\$s! Ihr Passwort wurde festgelegt." 92 | ::msgcat::mcset de MSG_BOT_USERLOGIN "Willkommen bei %1\$s! Sie sind jetzt als %2\$s eingeloggt." 93 | ::msgcat::mcset de MSG_BOT_USERLOGOUT "Sie sind jetzt als %1\$s ausgeloggt." 94 | ::msgcat::mcset de MSG_BOT_FIRSTLOGIN "Dies ist deine erste Anmeldung bei %1\$s." 95 | ::msgcat::mcset de MSG_BOT_LASTLOGIN "Das letzte Mal, als du dich bei %1\$s eingeloggt hast, war am %2\$s." 96 | ::msgcat::mcset de MSG_BOT_USERPASSWRONG "Diese Kombination aus Benutzername und Passwort ist mir unbekannt." 97 | ::msgcat::mcset de MSG_BOT_USERLOGGEDINAS "Du bist als %1\$s eingeloggt." 98 | ::msgcat::mcset de MSG_BOT_USERINFO "Dein Benutzername ist %1\$s\nDein Telegram-ID ist %2\$s\nDein letzter Telegram-Login war am %3\$s\nYour last Telegram-logout was at %4\$s\nDein letzter Telegram-login ID war %5\$s\nDein Telegram-account war am %6\$s erstellt\nDein IRC-account war am %7\$s erstellt\nDein letzter IRC-login war am %8\$s\nDein IRC-hostnames sind %9\$s\nDein IRC info ist %10\$s" 99 | ::msgcat::mcset de MSG_BOT_NOTLOGGEDIN "Du bist nicht eingeloggt." 100 | ::msgcat::mcset de MSG_BOT_UNAUTHORIZED "Du bist nicht dazu berechtigt." 101 | 102 | # Messages for IRC mode changes 103 | ::msgcat::mcset de MSG_IRC_CHANMODE_A "only admin joins allowed" 104 | ::msgcat::mcset de MSG_IRC_CHANMODE_a "channel admin" 105 | ::msgcat::mcset de MSG_IRC_CHANMODE_B "no capital-only messages allowed" 106 | ::msgcat::mcset de MSG_IRC_CHANMODE_b "ban" 107 | ::msgcat::mcset de MSG_IRC_CHANMODE_C "no CTCP allowed" 108 | ::msgcat::mcset de MSG_IRC_CHANMODE_c "no colors allowed" 109 | ::msgcat::mcset de MSG_IRC_CHANMODE_D "delay /join message" 110 | ::msgcat::mcset de MSG_IRC_CHANMODE_d "no messages after /join" 111 | ::msgcat::mcset de MSG_IRC_CHANMODE_E "no /me messages allowed" 112 | ::msgcat::mcset de MSG_IRC_CHANMODE_e "ban exception" 113 | ::msgcat::mcset de MSG_IRC_CHANMODE_F "trusted filter" 114 | ::msgcat::mcset de MSG_IRC_CHANMODE_f "flood control" 115 | ::msgcat::mcset de MSG_IRC_CHANMODE_G "censored words filter" 116 | ::msgcat::mcset de MSG_IRC_CHANMODE_g "censor specific word" 117 | ::msgcat::mcset de MSG_IRC_CHANMODE_H "display channel history on /join" 118 | ::msgcat::mcset de MSG_IRC_CHANMODE_h "half-op" 119 | ::msgcat::mcset de MSG_IRC_CHANMODE_I "invite exception" 120 | ::msgcat::mcset de MSG_IRC_CHANMODE_i "invite only" 121 | ::msgcat::mcset de MSG_IRC_CHANMODE_j "join-flood protection" 122 | ::msgcat::mcset de MSG_IRC_CHANMODE_K "no knock allowed" 123 | ::msgcat::mcset de MSG_IRC_CHANMODE_k "channel key" 124 | ::msgcat::mcset de MSG_IRC_CHANMODE_L "redirect if channel is full" 125 | ::msgcat::mcset de MSG_IRC_CHANMODE_l "limit amount of users" 126 | ::msgcat::mcset de MSG_IRC_CHANMODE_M "only registered users can speak" 127 | ::msgcat::mcset de MSG_IRC_CHANMODE_m "moderated" 128 | ::msgcat::mcset de MSG_IRC_CHANMODE_N "no nick changes" 129 | ::msgcat::mcset de MSG_IRC_CHANMODE_n "no external messages allowed" 130 | ::msgcat::mcset de MSG_IRC_CHANMODE_O "only operators can join" 131 | ::msgcat::mcset de MSG_IRC_CHANMODE_o "channel operator privileges" 132 | ::msgcat::mcset de MSG_IRC_CHANMODE_P "permanent channel" 133 | ::msgcat::mcset de MSG_IRC_CHANMODE_p "private" 134 | ::msgcat::mcset de MSG_IRC_CHANMODE_Q "no /kick allowed" 135 | ::msgcat::mcset de MSG_IRC_CHANMODE_q "channel owner" 136 | ::msgcat::mcset de MSG_IRC_CHANMODE_R "only registered users can join" 137 | ::msgcat::mcset de MSG_IRC_CHANMODE_r "channel is registered at services" 138 | ::msgcat::mcset de MSG_IRC_CHANMODE_S "strip colors" 139 | ::msgcat::mcset de MSG_IRC_CHANMODE_s "secret" 140 | ::msgcat::mcset de MSG_IRC_CHANMODE_T "no channel notices allowed" 141 | ::msgcat::mcset de MSG_IRC_CHANMODE_t "no topic changes allowed" 142 | ::msgcat::mcset de MSG_IRC_CHANMODE_u "auditorium" 143 | ::msgcat::mcset de MSG_IRC_CHANMODE_V "no invites allowed" 144 | ::msgcat::mcset de MSG_IRC_CHANMODE_v "the permission to talk" 145 | ::msgcat::mcset de MSG_IRC_CHANMODE_x "cloak hostname" 146 | ::msgcat::mcset de MSG_IRC_CHANMODE_Z "channel is secure-only" 147 | ::msgcat::mcset de MSG_IRC_CHANMODE_z "only secure connections allowed" 148 | -------------------------------------------------------------------------------- /lang/en.msg: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API module for Eggdrop - English language file v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # Messages from IRC to Telegram 8 | ::msgcat::mcset en MSG_IRC_MSGSENT "%1\$s@IRC: %2\$s" 9 | ::msgcat::mcset en MSG_IRC_NICKJOINED "%1\$s@IRC has entered %3\$s." 10 | ::msgcat::mcset en MSG_IRC_NICKLEFT "%1\$s@IRC has left %3\$s (%4\$s)." 11 | ::msgcat::mcset en MSG_IRC_NICKACTION "%1\$s@IRC: %2\$s %3\$s" 12 | ::msgcat::mcset en MSG_IRC_NICKCHANGE "%1\$s@IRC is now known as %2\$s" 13 | ::msgcat::mcset en MSG_IRC_TOPICCHANGE "%1\$s@IRC has changed the topic on %3\$s to %4\$s" 14 | ::msgcat::mcset en MSG_IRC_KICK "%1\$s@IRC has kicked %2\$s from %3\$s: %4\$s" 15 | ::msgcat::mcset en MSG_IRC_SETCHANMODE "%1\$s@IRC sets the channel mode %2\$s on %3\$s" 16 | ::msgcat::mcset en MSG_IRC_REMCHANMODE "%1\$s@IRC removes the channel mode %2\$s from %3\$s" 17 | ::msgcat::mcset en MSG_IRC_SETUSERMODE "%1\$s@IRC gives %2\$s to %3\$s on %4\$s" 18 | ::msgcat::mcset en MSG_IRC_REMUSERMODE "%1\$s@IRC takes %2\$s from %3\$s on %4\$s" 19 | 20 | # IRC service messages 21 | ::msgcat::mcset en MSG_IRC_INVITELINK "Join the Telegram %1\$s %2\$s here %3\$s" 22 | ::msgcat::mcset en MSG_IRC_DCCSENDFAILED "Could not send file. Please ask the admin to take a look at the log file." 23 | ::msgcat::mcset en MSG_IRC_DCCSENDFILE "Starting DCC transfer for %1\$s." 24 | ::msgcat::mcset en MSG_IRC_DCCSENDFULL "Can't send %1\$s (too many connections). Please try again later." 25 | ::msgcat::mcset en MSG_IRC_DCCSOCKET "Can't open a socket for the transfer of %1\$s." 26 | ::msgcat::mcset en MSG_IRC_DCCNOTFOUND "File %1\$s not found." 27 | ::msgcat::mcset en MSG_IRC_DCCQUEUED "File %1\$s is queued for transfer." 28 | 29 | # Messages from Telegram to IRC 30 | ::msgcat::mcset en MSG_TG_MSGSENT "%1\$s@Telegram: %2\$s" 31 | ::msgcat::mcset en MSG_TG_MSGREPLYTOSENT "%1\$s (in reply to %2\$s@Telegram: %3\$s)" 32 | ::msgcat::mcset en MSG_TG_MSGFORWARDED "%1\$s (forwarded from %2\$s)" 33 | ::msgcat::mcset en MSG_TG_MSGEDITED "%1\$s (message dated %2\$s was edited on %3\$s)" 34 | ::msgcat::mcset en MSG_TG_PINNEDMESSAGE "%1\$s@Telegram: %2\$s (pinned on %3\$s)" 35 | ::msgcat::mcset en MSG_TG_AUDIOSENT "%1\$s@Telegram has sent an audiofile: %2\$s - %3\$s (%4\$s s). Use !tgfile %5\$s to download the file." 36 | ::msgcat::mcset en MSG_TG_ANIMATIONSENT "%1\$s@Telegram has sent an animation%2\$s (%3\$s s). Use !tgfile %4\$s to download the file." 37 | ::msgcat::mcset en MSG_TG_DOCSENT "%1\$s@Telegram has sent a document%2\$s: %3\$s (%4\$s bytes). Use !tgfile %5\$s to download the file." 38 | ::msgcat::mcset en MSG_TG_PHOTOSENT "%1\$s@Telegram has sent a photo%2\$s (%3\$s bytes). Use !tgfile %4\$s to download the file." 39 | ::msgcat::mcset en MSG_TG_STICKERSENT "%1\$s@Telegram has sent a sticker from the %2\$s set (%3\$s)." 40 | ::msgcat::mcset en MSG_TG_VIDEOSENT "%1\$s@Telegram has sent a video%2\$s (%3\$s s). Use !tgfile %4\$s to download the file." 41 | ::msgcat::mcset en MSG_TG_VOICESENT "%1\$s@Telegram has sent a voice file: %2\$s (%3\$s bytes). Use !tgfile %4\$s to download the file." 42 | ::msgcat::mcset en MSG_TG_CONTACTSENT "%1\$s@Telegram has sent a contact: %2\$s (%3\$s %4\$s)." 43 | ::msgcat::mcset en MSG_TG_LOCATIONSENT "%1\$s@Telegram has sent a location: https://www.openstreetmap.org/#map=19/%3\$s/%2\$s" 44 | ::msgcat::mcset en MSG_TG_VENUESENT "%1\$s@Telegram has sent a venue: location=%2\$s title=%3\$s address=%4\$s foursquare_id=%5\$s." 45 | ::msgcat::mcset en MSG_TG_WELCOME "Welcome to %1\$s! I am %2\$s, the bartender in this Telegram group. I'm connected to the IRC channel %4\$s, so you can chat with the users on that channel as well." 46 | ::msgcat::mcset en MSG_TG_USERJOINED "%1\$s@Telegram has joined the Telegram group." 47 | ::msgcat::mcset en MSG_TG_USERADD "%1\$s@Telegram has added %2\$s to the Telegram group." 48 | ::msgcat::mcset en MSG_TG_USERLEFT "%1\$s@Telegram has left the Telegram group." 49 | ::msgcat::mcset en MSG_TG_USERREMOVED "%1\$s@Telegram has removed %2\$s from the Telegram group." 50 | ::msgcat::mcset en MSG_TG_TITLECHANGE "%1\$s@Telegram has changed the topic of the Telegram group to %2\$s." 51 | ::msgcat::mcset en MSG_TG_PICCHANGE "%1\$s@Telegram has changed the Telegram group picture. Use !tgfile %2\$s to download the file." 52 | ::msgcat::mcset en MSG_TG_PICDELETE "%1\$s@Telegram has removed the Telegram group picture." 53 | ::msgcat::mcset en MSG_TG_GROUPMIGRATED "%1$\s@Telegram has migrated the Telegram group to a supergroup." 54 | ::msgcat::mcset en MSG_TG_CHATTITLE "%1\$s is a %2\$s and is titled %3\$s" 55 | ::msgcat::mcset en MSG_TG_CHATDESC "%1\$s has a description: %2\$s" 56 | ::msgcat::mcset en MSG_TG_CHATMEMBERCOUNT "%1\$s has %2\$s members" 57 | ::msgcat::mcset en MSG_TG_CHATPHOTO "%1\$s has a chat photo: !tgfile %2\$s" 58 | ::msgcat::mcset en MSG_TG_UNKNOWNSTICKER "Unknown sticker." 59 | ::msgcat::mcset en MSG_TG_UNIMPL "Unknown Telegram message received: %1\$s" 60 | ::msgcat::mcset en MSG_WEBPREVIEW_UNAVAILABLE "Website preview available." 61 | ::msgcat::mcset en MSG_WEBPREVIEW_NOTITLE "No title available." 62 | 63 | # Messages for user commands for your bot 64 | ::msgcat::mcset en MSG_BOT_PUBHELP "I'm %1\$s, your personal bartender. Available commands are:\n" 65 | ::msgcat::mcset en MSG_BOT_PRVHELP "I'm %1\$s, your personal bartender. Available commands are:\n" 66 | ::msgcat::mcset en MSG_BOT_IRCINFO "The topic on %2\$s is: %3\$sThe channel mode is set to %4\$s" 67 | ::msgcat::mcset en MSG_BOT_IRCINFO_HELP ": Show information on the IRC channel(s) linked to this Telegram group." 68 | ::msgcat::mcset en MSG_BOT_IRCUSERS "The following users are known on %2\$s\:\n\n%3\$s" 69 | ::msgcat::mcset en MSG_BOT_IRCUSERS_HELP ": Show all users on the IRC channel(s) linked to this Telegram group." 70 | ::msgcat::mcset en MSG_BOT_IRCUSER "%1\$s@IRC is since %2\$s on %4\$s known as %5\$s" 71 | ::msgcat::mcset en MSG_BOT_IRCUSERUNKNOWN "%1\$s@IRC is not known on %3\$s" 72 | ::msgcat::mcset en MSG_BOT_IRCUSER_HELP " : Show detailed information about an user on IRC." 73 | ::msgcat::mcset en MSG_BOT_IRCKICKUSER "You've been kicked from this channel by a Telegram user." 74 | ::msgcat::mcset en MSG_BIT_IRCBANUSER "You've been banned from this channel by a Telegram user." 75 | ::msgcat::mcset en MSG_BOT_IRCKICK_HELP " : Kick an IRC user from the IRC channel." 76 | ::msgcat::mcset en MSG_BOT_IRCBAN_HELP " : Ban an IRC user from the IRC channel." 77 | ::msgcat::mcset en MSG_BOT_IRCUNBAN_HELP " : Unban an IRC user from the IRC channel." 78 | ::msgcat::mcset en MSG_BOT_IRCSETMODE_HELP " : Set the channel mode for the IRC channel." 79 | ::msgcat::mcset en MSG_BOT_TGWHOISNAME "Telegram ID %1\$s is %2\$s and is known as %3\$s%4\$s." 80 | ::msgcat::mcset en MSG_BOT_TGWHOISSTATUS "Telegram ID %1\$s has status %2\$s." 81 | ::msgcat::mcset en MSG_BOT_TGWHOISLANG "Telegram ID %1\$s has language code %2\$s." 82 | ::msgcat::mcset en MSG_BOT_TGWHOISPHOTO "Telegram ID %1\$s has an user profile photo set: !tgfile %2\$s" 83 | ::msgcat::mcset en MSG_BOT_TGUSERNOTVALID "No information available about Telegram ID %1\$s on this channel." 84 | ::msgcat::mcset en MSG_BOT_TGUSER "an user" 85 | ::msgcat::mcset en MSG_BOT_TGBOT "a bot" 86 | ::msgcat::mcset en MSG_BOT_TGUSERNOTVALID "Can't get information on Telegram ID %1\$s on this channel." 87 | ::msgcat::mcset en MSG_BOT_UNKNOWNCMD "I don't understand that. You can use /help to list all known commands." 88 | ::msgcat::mcset en MSG_BOT_GOTNOPRIVS "%1\$s isn't authorized to do that." 89 | 90 | # Messages for admins controlling your bot 91 | ::msgcat::mcset en MSG_BOT_PASSWORDSET "Welcome to %1\$s! Your password has been set." 92 | ::msgcat::mcset en MSG_BOT_USERLOGIN "Welcome to %1\$s! You're now logged in as %2\$s." 93 | ::msgcat::mcset en MSG_BOT_USERLOGOUT "You are now logged out as %1\$s." 94 | ::msgcat::mcset en MSG_BOT_FIRSTLOGIN "This is your first Telegram-login to %1\$s." 95 | ::msgcat::mcset en MSG_BOT_LASTLOGIN "The last time you logged in to %1\$s was at %2\$s." 96 | ::msgcat::mcset en MSG_BOT_USERPASSWRONG "That username and password combination is unknown to me." 97 | ::msgcat::mcset en MSG_BOT_USERLOGGEDINAS "You are logged in as %1\$s." 98 | ::msgcat::mcset en MSG_BOT_USERINFO "Your username is %1\$s\nYour Telegram-ID is %2\$s\nYour last Telegram-login was at %3\$s\nYour last Telegram-logout was at %4\$s\nYour last Telegram-login ID was %5\$s\nYour Telegram-account was created on %6\$s\nYour IRC-account was created at %7\$s\nYour last IRC-login was at %8\$s\nYour IRC-hostnames are %9\$s\nYour IRC info is %10\$s" 99 | ::msgcat::mcset en MSG_BOT_NOTLOGGEDIN "You're not logged in." 100 | ::msgcat::mcset en MSG_BOT_UNAUTHORIZED "You're not authorized to do that." 101 | 102 | # Messages for IRC mode changes 103 | ::msgcat::mcset en MSG_IRC_CHANMODE_A "only admin joins allowed" 104 | ::msgcat::mcset en MSG_IRC_CHANMODE_a "channel admin" 105 | ::msgcat::mcset en MSG_IRC_CHANMODE_B "no capital-only messages allowed" 106 | ::msgcat::mcset en MSG_IRC_CHANMODE_b "ban" 107 | ::msgcat::mcset en MSG_IRC_CHANMODE_C "no CTCP allowed" 108 | ::msgcat::mcset en MSG_IRC_CHANMODE_c "no colors allowed" 109 | ::msgcat::mcset en MSG_IRC_CHANMODE_D "delay /join message" 110 | ::msgcat::mcset en MSG_IRC_CHANMODE_d "no messages after /join" 111 | ::msgcat::mcset en MSG_IRC_CHANMODE_E "no /me messages allowed" 112 | ::msgcat::mcset en MSG_IRC_CHANMODE_e "ban exception" 113 | ::msgcat::mcset en MSG_IRC_CHANMODE_F "trusted filter" 114 | ::msgcat::mcset en MSG_IRC_CHANMODE_f "flood control" 115 | ::msgcat::mcset en MSG_IRC_CHANMODE_G "censored words filter" 116 | ::msgcat::mcset en MSG_IRC_CHANMODE_g "censor specific word" 117 | ::msgcat::mcset en MSG_IRC_CHANMODE_H "display channel history on /join" 118 | ::msgcat::mcset en MSG_IRC_CHANMODE_h "half-op" 119 | ::msgcat::mcset en MSG_IRC_CHANMODE_I "invite exception" 120 | ::msgcat::mcset en MSG_IRC_CHANMODE_i "invite only" 121 | ::msgcat::mcset en MSG_IRC_CHANMODE_j "join-flood protection" 122 | ::msgcat::mcset en MSG_IRC_CHANMODE_K "no knock allowed" 123 | ::msgcat::mcset en MSG_IRC_CHANMODE_k "channel key" 124 | ::msgcat::mcset en MSG_IRC_CHANMODE_L "redirect if channel is full" 125 | ::msgcat::mcset en MSG_IRC_CHANMODE_l "limit amount of users" 126 | ::msgcat::mcset en MSG_IRC_CHANMODE_M "only registered users can speak" 127 | ::msgcat::mcset en MSG_IRC_CHANMODE_m "moderated" 128 | ::msgcat::mcset en MSG_IRC_CHANMODE_N "no nick changes" 129 | ::msgcat::mcset en MSG_IRC_CHANMODE_n "no external messages allowed" 130 | ::msgcat::mcset en MSG_IRC_CHANMODE_O "only operators can join" 131 | ::msgcat::mcset en MSG_IRC_CHANMODE_o "channel operator privileges" 132 | ::msgcat::mcset en MSG_IRC_CHANMODE_P "permanent channel" 133 | ::msgcat::mcset en MSG_IRC_CHANMODE_p "private" 134 | ::msgcat::mcset en MSG_IRC_CHANMODE_Q "no /kick allowed" 135 | ::msgcat::mcset en MSG_IRC_CHANMODE_q "channel owner" 136 | ::msgcat::mcset en MSG_IRC_CHANMODE_R "only registered users can join" 137 | ::msgcat::mcset en MSG_IRC_CHANMODE_r "channel is registered at services" 138 | ::msgcat::mcset en MSG_IRC_CHANMODE_S "strip colors" 139 | ::msgcat::mcset en MSG_IRC_CHANMODE_s "secret" 140 | ::msgcat::mcset en MSG_IRC_CHANMODE_T "no channel notices allowed" 141 | ::msgcat::mcset en MSG_IRC_CHANMODE_t "no topic changes allowed" 142 | ::msgcat::mcset en MSG_IRC_CHANMODE_u "auditorium" 143 | ::msgcat::mcset en MSG_IRC_CHANMODE_V "no invites allowed" 144 | ::msgcat::mcset en MSG_IRC_CHANMODE_v "the permission to talk" 145 | ::msgcat::mcset en MSG_IRC_CHANMODE_x "cloak hostname" 146 | ::msgcat::mcset en MSG_IRC_CHANMODE_Z "channel is secure-only" 147 | ::msgcat::mcset en MSG_IRC_CHANMODE_z "only secure connections allowed" 148 | -------------------------------------------------------------------------------- /lang/nl.msg: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API module for Eggdrop - Dutch language file v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # Messages from IRC to Telegram 8 | ::msgcat::mcset nl MSG_IRC_MSGSENT "%1\$s@IRC: %2\$s" 9 | ::msgcat::mcset nl MSG_IRC_NICKJOINED "%1\$s@IRC is %3\$s binnengekomen." 10 | ::msgcat::mcset nl MSG_IRC_NICKLEFT "%1\$s@IRC heeft %3\$s verlaten (%4\$s)." 11 | ::msgcat::mcset nl MSG_IRC_NICKACTION "%1\$s@IRC: %2\$s %3\$s" 12 | ::msgcat::mcset nl MSG_IRC_NICKCHANGE "%1\$s@IRC heet nu %2\$s" 13 | ::msgcat::mcset nl MSG_IRC_TOPICCHANGE "%1\$s@IRC heeft het onderwerp op %3\$s veranderd naar %4\$s" 14 | ::msgcat::mcset nl MSG_IRC_KICK "%1\$s@IRC heeft %2\$s weggeschopt van %3\$s: %4\$s" 15 | ::msgcat::mcset nl MSG_IRC_SETCHANMODE "%1\$s@IRC zet de kanaalmode %2\$s op %3\$s" 16 | ::msgcat::mcset nl MSG_IRC_REMCHANMODE "%1\$s@IRC verwijdert de kanaalmode %2\$s van %3\$s" 17 | ::msgcat::mcset nl MSG_IRC_SETUSERMODE "%1\$s@IRC geeft %2\$s aan %3\$s op %4\$s" 18 | ::msgcat::mcset nl MSG_IRC_REMUSERMODE "%1\$s@IRC ontneemt %2\$s van %3\$s op %4\$s" 19 | 20 | # IRC service messages 21 | ::msgcat::mcset nl MSG_IRC_INVITELINK "Je kunt de Telegram %1\$s %2\$s hier vinden %3\$s" 22 | ::msgcat::mcset nl MSG_IRC_DCCSENDFAILED "Kan het bestand niet verzenden. Vraag de beheerder om naar de logbestanden te kijken." 23 | ::msgcat::mcset nl MSG_IRC_DCCSENDFILE "DCC overdracht van %1\$s wordt gestart." 24 | ::msgcat::mcset nl MSG_IRC_DCCSENDFULL "Kan %1\$s niet verzenden (te veel connecties). Probeer het later opnieuw." 25 | ::msgcat::mcset nl MSG_IRC_DCCSOCKET "Kan geen socket openen voor het versturen van %1\$s." 26 | ::msgcat::mcset nl MSG_IRC_DCCNOTFOUND "Bestand %1\$s niet gevonden." 27 | ::msgcat::mcset nl MSG_IRC_DCCQUEUED "Bestand %1\$s is in de wachtrij gezet om te verzenden." 28 | 29 | # Messages from Telegram to IRC 30 | ::msgcat::mcset nl MSG_TG_MSGSENT "%1\$s@Telegram: %2\$s" 31 | ::msgcat::mcset nl MSG_TG_MSGREPLYTOSENT "%1\$s (antwoord op %2\$s@Telegram: %3\$s)" 32 | ::msgcat::mcset nl MSG_TG_MSGFORWARDED "%1\$s (doorgestuurd van %2\$s)" 33 | ::msgcat::mcset nl MSG_TG_MSGEDITED "%1\$s (bericht van %2\$s is gewijzigd op %3\$s)" 34 | ::msgcat::mcset nl MSG_TG_PINNEDMESSAGE "%1\$s@Telegram: %2\$s (vastgezet op %3\$s)" 35 | ::msgcat::mcset nl MSG_TG_AUDIOSENT "%1\$s@Telegram heeft een audiobestand verstuurd: %2\$s - %3\$s (%4\$s s). Gebruik !tgfile %5\$s om het bestand te downloaden." 36 | ::msgcat::mcset nl MSG_TG_ANIMATIONSENT "%1\$s@Telegram heeft een animatie verstuurd%2\$s (%3\$s s). Gebruik !tgfile %4\$s om het bestand te downloaden." 37 | ::msgcat::mcset nl MSG_TG_DOCSENT "%1\$s@Telegram heeft een document verstuurd%2\$s: %3\$s (%4\$s bytes). Gebruik !tgfile %5\$s om het bestand te downloaden." 38 | ::msgcat::mcset nl MSG_TG_PHOTOSENT "%1\$s@Telegram heeft een foto verstuurd%2\$s (%3\$s bytes). Gebruik !tgfile %4\$s om het bestand te downloaden." 39 | ::msgcat::mcset nl MSG_TG_STICKERSENT "%1\$s@Telegram heeft een sticker uit de %2\$s serie verstuurd (%3\$s)." 40 | ::msgcat::mcset nl MSG_TG_VIDEOSENT "%1\$s@Telegram heeft een video verstuurd%2\$s (%3\$s s). Gebruik !tgfile %4\$s om het bestand te downloaden." 41 | ::msgcat::mcset nl MSG_TG_VOICESENT "%1\$s@Telegram heeft een voicebestand verstuurd: %2\$s (%3\$s bytes). Gebruik !tgfile %4\$s om het bestand te downloaden." 42 | ::msgcat::mcset nl MSG_TG_CONTACTSENT "%1\$s@Telegram heeft een contact verstuurd: %2\$s (%3\$s %4\$s)." 43 | ::msgcat::mcset nl MSG_TG_LOCATIONSENT "%1\$s@Telegram heeft een locatie verstuurd: https://www.openstreetmap.org/#map=19/%3\$s/%2\$s" 44 | ::msgcat::mcset nl MSG_TG_VENUESENT "%1\$s@Telegram heeft een venue verstuurd: location=%2\$s title=%3\$s address=%4\$s foursquare_id=%5\$s." 45 | ::msgcat::mcset nl MSG_TG_WELCOME "Welkom bij %1\$s! Ik ben %2\$s, de barkeeper in deze Telegram groep. Ik ben verbonden het het IRC kanaal %4\$s zodat je ook met de gebruikers op dat kanaal kunt praten." 46 | ::msgcat::mcset nl MSG_TG_USERJOINED "%1\$s@Telegram is nu lid van de Telegram groep." 47 | ::msgcat::mcset nl MSG_TG_USERADD "%1\$s@Telegram heeft %2\$s aan de Telegram groep toegevoegd." 48 | ::msgcat::mcset nl MSG_TG_USERLEFT "%1\$s@Telegram heeft de Telegram groep verlaten." 49 | ::msgcat::mcset nl MSG_TG_USERREMOVED "%1\$s@Telegram heeft %2\$s uit de Telegram groep verwijderd." 50 | ::msgcat::mcset nl MSG_TG_TITLECHANGE "%1\$s@Telegram heeft het onderwerp van de Telegram groep gewijzigd naar %2\$s." 51 | ::msgcat::mcset nl MSG_TG_PICCHANGE "%1\$s@Telegram heeft de afbeelding van de Telegram groep gewijzigd. Gebruik !tgfile %2\$s om het bestand te downloaden." 52 | ::msgcat::mcset nl MSG_TG_PICDELETE "%1\$s@Telegram heeft de afbeelding van de Telegram groep verwijderd." 53 | ::msgcat::mcset nl MSG_TG_GROUPMIGRATED "%1$\s@Telegram heeft de Telegram groep gemigreerd naar een supergroep." 54 | ::msgcat::mcset nl MSG_TG_CHATTITLE "%1\$s is een %2\$s en heet %3\$s" 55 | ::msgcat::mcset nl MSG_TG_CHATDESC "%1\$s heeft als beschrijving: %2\$s" 56 | ::msgcat::mcset nl MSG_TG_CHATMEMBERCOUNT "%1\$s heeft %2\$s leden" 57 | ::msgcat::mcset nl MSG_TG_CHATPHOTO "%1\$s heeft een groepsfoto ingesteld: !tgfile %2\$s" 58 | ::msgcat::mcset nl MSG_TG_UNKNOWNSTICKER "Onbekende sticker." 59 | ::msgcat::mcset nl MSG_TG_UNIMPL "Onbekend Telegram bericht ontvangen: %1\$s" 60 | ::msgcat::mcset nl MSG_WEBPREVIEW_UNAVAILABLE "Website niet beschikbaar." 61 | ::msgcat::mcset nl MSG_WEBPREVIEW_NOTITLE "Website heeft geen titel." 62 | 63 | # Messages for user commands for your bot 64 | ::msgcat::mcset nl MSG_BOT_PUBHELP "Ik ben %1\$s, je persoonlijke barkeeper. De beschikbare commando's zijn:" 65 | ::msgcat::mcset nl MSG_BOT_PRVHELP "Ik ben %1\$s, je persoonlijke barkeeper. De beschikbare commando's zijn:\n" 66 | ::msgcat::mcset nl MSG_BOT_IRCINFO "Het onderwerp op %2\$s is: %3\$s\nDe kanaalmodus is ingesteld op %4\$s" 67 | ::msgcat::mcset nl MSG_BOT_IRCINFO_HELP ": Laat informatie over het IRC kanaal zien." 68 | ::msgcat::mcset nl MSG_BOT_IRCUSERS "Op %2\$s\ zijn de volgende gebruikers bekend:\n\n%3\$s" 69 | ::msgcat::mcset nl MSG_BOT_IRCUSERS_HELP ": Geeft alle gebruikers op het IRC kanaal weer." 70 | ::msgcat::mcset nl MSG_BOT_IRCUSER "%1\$s@IRC is sinds %2\$s op %4\$s bekend als %5\$s" 71 | ::msgcat::mcset nl MSG_BOT_IRCUSERUNKNOWN "%1\$s@IRC is niet bekend op %3\$s" 72 | ::msgcat::mcset nl MSG_BOT_IRCUSER_HELP " : Laat gedetailleerde informatie zien over een gebruiker op IRC." 73 | ::msgcat::mcset nl MSG_BOT_IRCKICKUSER "Je bent door een Telegram gebruiker van dit kanaal getrapt." 74 | ::msgcat::mcset nl MSG_BOT_IRCBANUSER "Je bent door een Telegram gebruiker van dit kanaal verbannen." 75 | ::msgcat::mcset nl MSG_BOT_IRCKICK_HELP " : Trap een gebruiker op IRC van het IRC kanaal af." 76 | ::msgcat::mcset nl MSG_BOT_IRCBAN_HELP " : Verbant een gebruiker op IRC van het IRC kanaal." 77 | ::msgcat::mcset nl MSG_BOT_IRCUNBAN_HELP " : Hef een verbanning van een gebruiker op IRC op het IRC kanaal op." 78 | ::msgcat::mcset nl MSG_BOT_IRCSETMODE_HELP " : Zet een kanaalmodus voor het IRC kanaal." 79 | ::msgcat::mcset nl MSG_BOT_TGWHOISNAME "Telegram ID %1\$s is %2\$s en is bekend als %3\$s%4\$s." 80 | ::msgcat::mcset nl MSG_BOT_TGWHOISSTATUS "Telegram ID %1\$s heeft als status %2\$s." 81 | ::msgcat::mcset nl MSG_BOT_TGWHOISLANG "Telegram ID %1\$s heeft als taalcode %2\$s." 82 | ::msgcat::mcset nl MSG_BOT_TGWHOISPHOTO "Telegram ID %1\$s heeft een gebruikersfoto ingesteld: !tgfile %2\$s" 83 | ::msgcat::mcset nl MSG_BOT_TGUSERNOTVALID "Kan op dit kanaal geen informatie ophalen over Telegram ID %1\$s." 84 | ::msgcat::mcset nl MSG_BOT_TGUSER "een gebruiker" 85 | ::msgcat::mcset nl MSG_BOT_TGBOT "een bot" 86 | ::msgcat::mcset nl MSG_BOT_UNKNOWNCMD "Dat snap ik niet. Type /help om een overzicht van alle commando's te bekijken." 87 | ::msgcat::mcset nl MSG_BOT_GOTNOPRIVS "%1\$s heeft niet voldoende rechten om dat te doen." 88 | 89 | # Messages for admins controlling your bot 90 | ::msgcat::mcset nl MSG_BOT_PASSWORDSET "Welkom op %1\$s! Je wachtwoord is nu ingesteld." 91 | ::msgcat::mcset nl MSG_BOT_USERLOGIN "Welkom op %1\$s! Je bent nu ingelogd als %2\$s." 92 | ::msgcat::mcset nl MSG_BOT_USERLOGOUT "Je bent nu uitgelogd als %1\$s." 93 | ::msgcat::mcset nl MSG_BOT_FIRSTLOGIN "Dit is de eerste keer dat je via Telegram inlogt op %1\$s." 94 | ::msgcat::mcset nl MSG_BOT_LASTLOGIN "De laatste keer dat je via Telegram hebt ingelogd op %1\$s was op %1\$s." 95 | ::msgcat::mcset nl MSG_BOT_USERPASSWRONG "De combinatie van die gebruikersnaam en wachtwoord is onbekend." 96 | ::msgcat::mcset nl MSG_BOT_USERLOGGEDINAS "Je bent ingelogd als %1\$s." 97 | ::msgcat::mcset nl MSG_BOT_USERINFO "Je gebruikersnaam is %1\$s\nJe Telegram-ID is %2\$s\nJe laatste login was om %3\$s\nJe laatste logout was om %4\$s\nJe vorige login was met Telegram-ID %5\$s\nJe Telegram-account is op %6\$s aangemaakt\nJe IRC-account is op %7\$s aangemaakt\nJe laatste login op IRC was om %8\$s\nJe hostnamen op IRC zijn %9\$s\nJe IRC info is %10\$s" 98 | ::msgcat::mcset nl MSG_BOT_NOTLOGGEDIN "Je bent niet ingelogd." 99 | ::msgcat::mcset nl MSG_BOT_UNAUTHORIZED "Je bent niet geauthoriseerd om dat te doen." 100 | 101 | # Messages for IRC mode changes 102 | ::msgcat::mcset nl MSG_IRC_CHANMODE_A "only admin joins allowed" 103 | ::msgcat::mcset nl MSG_IRC_CHANMODE_a "channel admin" 104 | ::msgcat::mcset nl MSG_IRC_CHANMODE_B "no capital-only messages allowed" 105 | ::msgcat::mcset nl MSG_IRC_CHANMODE_b "ban" 106 | ::msgcat::mcset nl MSG_IRC_CHANMODE_C "no CTCP allowed" 107 | ::msgcat::mcset nl MSG_IRC_CHANMODE_c "no colors allowed" 108 | ::msgcat::mcset nl MSG_IRC_CHANMODE_D "delay /join message" 109 | ::msgcat::mcset nl MSG_IRC_CHANMODE_d "no messages after /join" 110 | ::msgcat::mcset nl MSG_IRC_CHANMODE_E "no /me messages allowed" 111 | ::msgcat::mcset nl MSG_IRC_CHANMODE_e "ban exception" 112 | ::msgcat::mcset nl MSG_IRC_CHANMODE_F "trusted filter" 113 | ::msgcat::mcset nl MSG_IRC_CHANMODE_f "flood control" 114 | ::msgcat::mcset nl MSG_IRC_CHANMODE_G "censored words filter" 115 | ::msgcat::mcset nl MSG_IRC_CHANMODE_g "censor specific word" 116 | ::msgcat::mcset nl MSG_IRC_CHANMODE_H "display channel history on /join" 117 | ::msgcat::mcset nl MSG_IRC_CHANMODE_h "half-op" 118 | ::msgcat::mcset nl MSG_IRC_CHANMODE_I "invite exception" 119 | ::msgcat::mcset nl MSG_IRC_CHANMODE_i "invite only" 120 | ::msgcat::mcset nl MSG_IRC_CHANMODE_j "join-flood protection" 121 | ::msgcat::mcset nl MSG_IRC_CHANMODE_K "no knock allowed" 122 | ::msgcat::mcset nl MSG_IRC_CHANMODE_k "channel key" 123 | ::msgcat::mcset nl MSG_IRC_CHANMODE_L "redirect if channel is full" 124 | ::msgcat::mcset nl MSG_IRC_CHANMODE_l "limit amount of users" 125 | ::msgcat::mcset nl MSG_IRC_CHANMODE_M "only registered users can speak" 126 | ::msgcat::mcset nl MSG_IRC_CHANMODE_m "moderated" 127 | ::msgcat::mcset nl MSG_IRC_CHANMODE_N "no nick changes" 128 | ::msgcat::mcset nl MSG_IRC_CHANMODE_n "no external messages allowed" 129 | ::msgcat::mcset nl MSG_IRC_CHANMODE_O "only operators can join" 130 | ::msgcat::mcset nl MSG_IRC_CHANMODE_o "channel operator privileges" 131 | ::msgcat::mcset nl MSG_IRC_CHANMODE_P "permanent channel" 132 | ::msgcat::mcset nl MSG_IRC_CHANMODE_p "private" 133 | ::msgcat::mcset nl MSG_IRC_CHANMODE_Q "no /kick allowed" 134 | ::msgcat::mcset nl MSG_IRC_CHANMODE_q "channel owner" 135 | ::msgcat::mcset nl MSG_IRC_CHANMODE_R "only registered users can join" 136 | ::msgcat::mcset nl MSG_IRC_CHANMODE_r "channel is registered at services" 137 | ::msgcat::mcset nl MSG_IRC_CHANMODE_S "strip colors" 138 | ::msgcat::mcset nl MSG_IRC_CHANMODE_s "secret" 139 | ::msgcat::mcset nl MSG_IRC_CHANMODE_T "no channel notices allowed" 140 | ::msgcat::mcset nl MSG_IRC_CHANMODE_t "no topic changes allowed" 141 | ::msgcat::mcset nl MSG_IRC_CHANMODE_u "auditorium" 142 | ::msgcat::mcset nl MSG_IRC_CHANMODE_V "no invites allowed" 143 | ::msgcat::mcset nl MSG_IRC_CHANMODE_v "the permission to talk" 144 | ::msgcat::mcset nl MSG_IRC_CHANMODE_x "cloak hostname" 145 | ::msgcat::mcset nl MSG_IRC_CHANMODE_Z "channel is secure-only" 146 | ::msgcat::mcset nl MSG_IRC_CHANMODE_z "only secure connections allowed" 147 | -------------------------------------------------------------------------------- /lib/libhttp.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # HTTP web request library for Tcl - v20180222 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | 8 | namespace eval libhttp { 9 | variable ::libhttp::processor "" 10 | variable ::libhttp::status 11 | variable ::libhttp::result 12 | variable ::libhttp::errorMessage "" 13 | variable ::libhttp::errorNumber 0 14 | } 15 | 16 | # ---------------------------------------------------------------------------- # 17 | # Make a HTTP GET request and return the response # 18 | # ---------------------------------------------------------------------------- # 19 | proc ::libhttp::get {url {parameters ""}} { 20 | variable urldata "" 21 | set ::libhttp::errorNumber 0 22 | 23 | switch $::libjson::processor { 24 | "http_pkg" { 25 | if {![catch {package present http}] || ![catch {package present tls}]} { 26 | set ::libhttp::errorMessage "::libhttp::get: Tcllib::http processor not supported" 27 | set ::libhttp::errorNumber -1 28 | } 29 | 30 | foreach data value [list $parameters] { 31 | append urldata "$data=$value&" 32 | } 33 | 34 | ::http::register https 443 [list ::tls::socket -tls1 1 -ssl2 0 -ssl3 0] 35 | set token [::http::geturl "$url?$urldata"] 36 | set ::libhttp::status [::http::status $token] 37 | set ::libhttp::result [::http::data $token] 38 | ::http::cleanup $token 39 | ::http::unregister https 40 | } 41 | 42 | "curl" { 43 | foreach data value [list $parameters] { 44 | append urldata " -d $data=$value" 45 | } 46 | 47 | if { [ catch { 48 | set ::libhttp::result [exec curl --tlsv1.2 -s -X GET $url $urldata] 49 | } ] } { 50 | set ::libhttp::errorMessage "::libhttp::get: cannot connect to $url" 51 | set ::libhttp::errorNumber -2 52 | } 53 | } 54 | 55 | default { 56 | set ::libhttp::errorMessage "::libhttp::get unknown http processor $::libhttp::processor" 57 | set ::libhttp::errorNumber -3 58 | } 59 | } 60 | return $::libhttp::errorNumber 61 | } 62 | 63 | # ---------------------------------------------------------------------------- # 64 | # Make a HTTP POST request and return the response # 65 | # ---------------------------------------------------------------------------- # 66 | proc ::libhttp::post {url parameters} { 67 | variable urldata "" 68 | set ::libhttp::errorNumber 0 69 | 70 | switch $::libjson::processor { 71 | "http_pkg" { 72 | if {![catch {package present http}] || ![catch {package present tls}]} { 73 | set ::libhttp::errormessage "::libhttp::post: Tcllib::http processor not supported" 74 | set ::libhttp::errornumber -1 75 | } 76 | 77 | ::http::register https 443 [list ::tls::socket -tls1 1 -ssl2 0 -ssl3 0] 78 | set token [::http::geturl $url -query [::http::formatQuery [list $parameters]]] 79 | set ::libhttp::status [::http::status $token] 80 | set ::libhttp::result [::http::data $token] 81 | ::http::cleanup $token 82 | ::http::unregister https 83 | } 84 | 85 | "curl" { 86 | foreach data value [list $parameters] { 87 | append urldata " -d $data=$value" 88 | } 89 | 90 | if { [ catch { 91 | set ::libhttp::result [exec curl --tlsv1.2 -s -X POST $url $urldata] 92 | } ] } { 93 | set ::libhttp::errorMessage "::libhttp::post: cannot connect to $url" 94 | set ::libhttp::errorNumber -2 95 | } 96 | } 97 | 98 | default { 99 | set ::libhttp::errorMessage "::libhttp::post unknown http processor $::libhttp::processor" 100 | set ::libhttp::errorNumber -3 101 | } 102 | } 103 | return $::libhttp::errorNumber 104 | } 105 | 106 | if {$::libhttp::processor eq ""} { 107 | if {[catch {package present http}] && [catch {package present tls}]} { 108 | package require http 109 | package require tls 110 | set ::libhttp::processor "http_pkg" 111 | } else { 112 | set ::libhttp::processor "curl" 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /lib/libjson.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # JSON library for Tcl - v20180222 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | 8 | namespace eval libjson { 9 | variable ::libjson::processor 10 | variable ::libjson::result 11 | variable ::libjson::errorMessage "" 12 | variable ::libjson::errorNumber 0 13 | } 14 | 15 | # ---------------------------------------------------------------------------- # 16 | # Check if a JSON key is present # 17 | # ---------------------------------------------------------------------------- # 18 | proc ::libjson::hasKey {record key} { 19 | set ::libjson::errornumber 0 20 | 21 | switch $::libjson::processor { 22 | "json_pkg" { 23 | set ::libjson::errorMessage "Tcllib::json json processor not supported" 24 | set ::libjson::errornumber -1 25 | return -1 26 | } 27 | 28 | "jq" { 29 | if { [ catch { 30 | set ::libjson::result [exec jq --raw-output $key << $record] 31 | } ] } { 32 | set ::libjson::errorMessage "libjson: cannot exec jq (key=$key, record=$record)" 33 | set ::libjson::errornumber -1 34 | return -1 35 | } 36 | if {$::libjson::result != "null"} { 37 | return true 38 | } else { 39 | return false 40 | } 41 | } 42 | 43 | "internal" { 44 | return [::libjson::internal::hasKey $record $key] 45 | } 46 | 47 | default { 48 | set ::libjson::errorMessage "::libjson::hasKey unknown json processor $::libjson::processor" 49 | set ::libjson::errornumber -1 50 | return -1 51 | } 52 | } 53 | } 54 | 55 | # ---------------------------------------------------------------------------- # 56 | # Return the value of a JSON key # 57 | # ---------------------------------------------------------------------------- # 58 | proc ::libjson::getValue {record key} { 59 | set ::libjson::errornumber 0 60 | 61 | switch $::libjson::processor { 62 | "json_pkg" { 63 | set ::libjson::errorMessage "Tcllib::json json processor not supported" 64 | set ::libjson::errornumber -1 65 | return -1 66 | } 67 | 68 | "jq" { 69 | # http://wiki.tcl.tk/11630 70 | if { [ catch { 71 | set ::libjson::result [exec jq --raw-output --compact-output $key << $record] 72 | } ] } { 73 | set ::libjson::errorMessage "libjson: cannot exec jq (key=$key, record=$record)" 74 | set ::libjson::errornumber -1 75 | return -1 76 | } 77 | return $::libjson::result 78 | } 79 | 80 | "internal" { 81 | set object "tmp" 82 | return [::libjson::internal::getValue $record $object $key] 83 | } 84 | 85 | default { 86 | set ::libjson::errorMessage "::libjson::hasKey unknown json processor $::libjson::processor" 87 | set ::libjson::errornumber -1 88 | return -1 89 | } 90 | } 91 | } 92 | 93 | namespace eval ::libjson::internal {} 94 | 95 | # ---------------------------------------------------------------------------- # 96 | # Check if a JSON key is present # 97 | # ---------------------------------------------------------------------------- # 98 | proc ::libjson::internal::hasKey {record key} { 99 | if {[string first [string range $key [string last "." $key]+1 end] $record] != -1} { 100 | return 1 101 | } else { 102 | return 0 103 | } 104 | } 105 | 106 | # ---------------------------------------------------------------------------- # 107 | # Return the value of a JSON key # 108 | # ---------------------------------------------------------------------------- # 109 | proc ::libjson::internal::getValue {record object key} { 110 | set length [string length $key] 111 | set objectstart [string first "\"$object\":\{" $record] 112 | # Bug: this is a quick fix because this procedure doesn't iterate through all the objects correctly yet 113 | if {$object eq ""} { 114 | set objectend [string length $record] 115 | } else { 116 | set objectend [string first "\}" $record $objectstart] 117 | } 118 | 119 | set keystart [string first "\"$key\":" $record $objectstart] 120 | if {$keystart != -1} { 121 | if {$keystart < $objectend} { 122 | if {[string index $record [expr $keystart+$length+3]] eq "\""} { 123 | set end [string first "\"" $record [expr $keystart+$length+5]] 124 | return [string range $record [expr $keystart+$length+4] $end-1] 125 | } else { 126 | set end [string first "," $record [expr $keystart+$length+3]] 127 | if {$end != -1} { 128 | return [string range $record [expr $keystart+$length+3] $end-1] 129 | } else { 130 | set end [string first "\}" $record [expr $keystart+$length+3]] 131 | if {$end != -1} { 132 | return [string trim [string range $record [expr $keystart+$length+3] $end-1]] 133 | } else { 134 | return "UNKNOWN" 135 | } 136 | } 137 | } 138 | } 139 | } 140 | return "" 141 | } 142 | 143 | set ::libjson::processor "jq" 144 | 145 | # Default JSON processor is Tcl's json package 146 | #set ::libjson::processor "json_pkg" 147 | 148 | # Fall back to jq if the json package isn't available 149 | #if { [ catch { 150 | # package require json 151 | #} ] } { 152 | # set ::libjson::processor "jq" 153 | #} 154 | 155 | # Fall back to internal code in this library if both the json package and jq aren't available 156 | #if { [catch { 157 | # [exec jq --help] 158 | #} ] } { 159 | # set ::libjson::processor "internal" 160 | #} 161 | -------------------------------------------------------------------------------- /lib/libtelegram.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram API library for Tcl - v20180810 # 3 | # This library has functions for interacting with the Telegram servers # 4 | # # 5 | # written by Eelco Huininga 2016-2018 # 6 | # ---------------------------------------------------------------------------- # 7 | 8 | namespace eval libtelegram { 9 | variable ::libtelegram::bot_id 10 | variable ::libtelegram::bot_token 11 | variable ::libtelegram::result 12 | variable ::libtelegram::errorMessage 13 | variable ::libtelegram::errorNumber 14 | set ::libtelegram::max_file_size 20480000 15 | } 16 | 17 | # ---------------------------------------------------------------------------- # 18 | # ::libtelegram::getUpdates # 19 | # ---------------------------------------------------------------------------- # 20 | # Receive incoming updates from the Telegram servers # 21 | # https://core.telegram.org/bots/api#getUpdates # 22 | # ---------------------------------------------------------------------------- # 23 | proc ::libtelegram::getUpdates {offset} { 24 | if { [catch { 25 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getUpdates -d offset=$offset] 26 | } ] } { 27 | set ::libtelegram::errorMessage "libtelegram::getUpdates: cannot connect to api.telegram.com." 28 | return [set ::libtelegram::errorNumber -1] 29 | } else { 30 | if {![::libtelegram::checkValidResult]} { 31 | set ::libtelegram::errorMessage "libtelegram::getUpdates: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 32 | return $::libtelegram::errorNumber 33 | } 34 | } 35 | 36 | return [set ::libtelegram::errorNumber 0] 37 | } 38 | 39 | # ---------------------------------------------------------------------------- # 40 | # ::libtelegram::setWebHook # 41 | # ---------------------------------------------------------------------------- # 42 | # Specify a url and receive incoming updates via an outgoing webhook # 43 | # https://core.telegram.org/bots/api#setwebhook # 44 | # ---------------------------------------------------------------------------- # 45 | proc ::libtelegram::setWebHook {url certificate max_connections allowed_updates} { 46 | if { [ catch { 47 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/setWebHook -d url=$url -d certificate=$certificate -d max_connections=$max_connections -d allowed_updates=$allowed_updates] 48 | } ] } { 49 | set ::libtelegram::errorMessage "libtelegram::setWebHook: cannot connect to api.telegram.com." 50 | return [set ::libtelegram::errorNumber -1] 51 | } else { 52 | if {![::libtelegram::checkValidResult]} { 53 | set ::libtelegram::errorMessage "libtelegram::setWebHook: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 54 | return $::libtelegram::errorNumber 55 | } 56 | } 57 | 58 | return [set ::libtelegram::errorNumber 0] 59 | } 60 | 61 | # ---------------------------------------------------------------------------- # 62 | # ::libtelegram::deleteWebHook # 63 | # ---------------------------------------------------------------------------- # 64 | # Removes a webhook # 65 | # https://core.telegram.org/bots/api#deletewebhook # 66 | # ---------------------------------------------------------------------------- # 67 | proc ::libtelegram::deleteWebHook {} { 68 | if { [ catch { 69 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/deleteWebHook] 70 | } ] } { 71 | set ::libtelegram::errorMessage "libtelegram::deleteWebHook: cannot connect to api.telegram.com." 72 | return [set ::libtelegram::errorNumber -1] 73 | } else { 74 | if {![::libtelegram::checkValidResult]} { 75 | set ::libtelegram::errorMessage "libtelegram::deleteWebHook: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 76 | return $::libtelegram::errorNumber 77 | } 78 | } 79 | 80 | return [set ::libtelegram::errorNumber 0] 81 | } 82 | 83 | # ---------------------------------------------------------------------------- # 84 | # ::libtelegram::getWebHookInfo # 85 | # ---------------------------------------------------------------------------- # 86 | # Returns info on the current webhook # 87 | # https://core.telegram.org/bots/api#getwebhookinfo # 88 | # ---------------------------------------------------------------------------- # 89 | proc ::libtelegram::getWebHookInfo {} { 90 | if { [ catch { 91 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getWebHookInfo] 92 | } ] } { 93 | set ::libtelegram::errorMessage "libtelegram::getWebHookInfo: cannot connect to api.telegram.com." 94 | return [set ::libtelegram::errorNumber -1] 95 | } else { 96 | if {![::libtelegram::checkValidResult]} { 97 | set ::libtelegram::errorMessage "libtelegram::getWebHookInfo: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 98 | return $::libtelegram::errorNumber 99 | } 100 | } 101 | 102 | return [set ::libtelegram::errorNumber 0] 103 | } 104 | 105 | # ---------------------------------------------------------------------------- # 106 | # ::libtelegram::getMe # 107 | # ---------------------------------------------------------------------------- # 108 | # Get some basic information about the bot # 109 | # https://core.telegram.org/bots/api#getMe # 110 | # ---------------------------------------------------------------------------- # 111 | proc ::libtelegram::getMe {} { 112 | if { [ catch { 113 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getMe] 114 | } ] } { 115 | set ::libtelegram::errorMessage "libtelegram::getMe: cannot connect to api.telegram.com." 116 | return [set ::libtelegram::errorNumber -1] 117 | } else { 118 | if {![::libtelegram::checkValidResult]} { 119 | set ::libtelegram::errorMessage "libtelegram::getMe: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 120 | return $::libtelegram::errorNumber 121 | } 122 | } 123 | 124 | return [set ::libtelegram::errornumber 0] 125 | } 126 | 127 | # ---------------------------------------------------------------------------- # 128 | # ::libtelegram::sendMessage # 129 | # ---------------------------------------------------------------------------- # 130 | # Sends a message to a chat group in Telegram # 131 | # https://core.telegram.org/bots/api#sendmessage # 132 | # ---------------------------------------------------------------------------- # 133 | proc ::libtelegram::sendMessage {chat_id text parse_mode disable_notification reply_to_message_id reply_markup} { 134 | if { [ catch { 135 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendMessage -d chat_id=$chat_id -d text=$text -d parse_mode=$parse_mode -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 136 | } ] } { 137 | putlog "[set ::libtelegram::errorMessage "libtelegram::sendMessage: cannot connect to api.telegram.com."]" 138 | return [set ::libtelegram::errorNumber -1] 139 | } else { 140 | if {![::libtelegram::checkValidResult]} { 141 | putlog "[set ::libtelegram::errorMessage "libtelegram::sendMessage: $::libtelegram::errorNumber - $::libtelegram::errorMessage"]" 142 | return $::libtelegram::errorNumber 143 | } 144 | } 145 | 146 | return [set ::libtelegram::errornumber 0] 147 | } 148 | 149 | # ---------------------------------------------------------------------------- # 150 | # ::libtelegram::forwardMessage # 151 | # ---------------------------------------------------------------------------- # 152 | # Forwards a message to a user or a chat group in Telegram # 153 | # https://core.telegram.org/bots/api#forwardmessage # 154 | # ---------------------------------------------------------------------------- # 155 | proc ::libtelegram::forwardMessage {chat_id from_chat_id disable_notification message_id} { 156 | if { [ catch { 157 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/forwardMessage -d chat_id=$chat_id -d from_chat_id=$from_chat_id -d disable_notification=$disable_notification -d message_id=$message_id] 158 | } ] } { 159 | set ::libtelegram::errorMessage "libtelegram::forwardMessage: cannot connect to api.telegram.com." 160 | return [set ::libtelegram::errorNumber -1] 161 | } else { 162 | if {![::libtelegram::checkValidResult]} { 163 | set ::libtelegram::errorMessage "libtelegram::forwardMessage: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 164 | return $::libtelegram::errorNumber 165 | } 166 | } 167 | 168 | return [set ::libtelegram::errornumber 0] 169 | } 170 | 171 | # ---------------------------------------------------------------------------- # 172 | # ::libtelegram::sendPhoto # 173 | # ---------------------------------------------------------------------------- # 174 | # sendPhoto: Sends a photo to a chat group in Telegram # 175 | # https://core.telegram.org/bots/api#sendphoto # 176 | # ---------------------------------------------------------------------------- # 177 | proc ::libtelegram::sendPhoto {chat_id photo caption parse_mode disable_notification reply_to_message_id reply_markup} { 178 | if { [ catch { 179 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendPhoto -d chat_id=$chat_id -d photo=$photo -d caption=$caption -d parse_mode=$parse_mode -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 180 | } ] } { 181 | set ::libtelegram::errorMessage "libtelegram::sendPhoto: cannot connect to api.telegram.com." 182 | return [set ::libtelegram::errorNumber -1] 183 | } else { 184 | if {![::libtelegram::checkValidResult]} { 185 | set ::libtelegram::errorMessage "libtelegram::sendPhoto: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 186 | return $::libtelegram::errorNumber 187 | } 188 | } 189 | 190 | return [set ::libtelegram::errornumber 0] 191 | } 192 | 193 | # ---------------------------------------------------------------------------- # 194 | # ::libtelegram::sendAudio # 195 | # ---------------------------------------------------------------------------- # 196 | # sendAudio: Sends a audio file to a chat group in Telegram # 197 | # https://core.telegram.org/bots/api#sendaudio # 198 | # ---------------------------------------------------------------------------- # 199 | proc ::libtelegram::sendAudio {chat_id audio caption parse_mode duration performer title thumb disable_notification reply_to_message_id reply_markup} { 200 | if { [ catch { 201 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendAudio -d chat_id=$chat_id -d audio=$audio -d caption=$caption -d parse_mode=$parse_mode -d duration=$duration -d performer=$performer -d title=$title -d thumb=thumb -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 202 | } ] } { 203 | set ::libtelegram::errorMessage "libtelegram::sendAudio: cannot connect to api.telegram.com." 204 | return [set ::libtelegram::errorNumber -1] 205 | } else { 206 | if {![::libtelegram::checkValidResult]} { 207 | set ::libtelegram::errorMessage "libtelegram::sendAudio: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 208 | return $::libtelegram::errorNumber 209 | } 210 | } 211 | 212 | return [set ::libtelegram::errornumber 0] 213 | } 214 | 215 | # ---------------------------------------------------------------------------- # 216 | # ::libtelegram::sendDocument # 217 | # ---------------------------------------------------------------------------- # 218 | # sendDocument: Sends a document to a chat group in Telegram # 219 | # https://core.telegram.org/bots/api#senddocument # 220 | # ---------------------------------------------------------------------------- # 221 | proc ::libtelegram::sendDocument {chat_id document thumb caption parse_mode disable_notification reply_to_message_id reply_markup} { 222 | if { [ catch { 223 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendDocument -d chat_id=$chat_id -d document=$document -d thumb=$thumb -d caption=$caption -d parse_mode=$parse_mode -d disable+_notification=$disable_notification -d reply_to_message_id=$ reply_to_message_id -d reply_markup=$markup] 224 | } ] } { 225 | set ::libtelegram::errorMessage "libtelegram::sendDocument: cannot connect to api.telegram.com." 226 | return [set ::libtelegram::errorNumber -1] 227 | } else { 228 | if {![::libtelegram::checkValidResult]} { 229 | set ::libtelegram::errorMessage "libtelegram::sendDocument: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 230 | return $::libtelegram::errorNumber 231 | } 232 | } 233 | 234 | return [set ::libtelegram::errornumber 0] 235 | } 236 | 237 | # ---------------------------------------------------------------------------- # 238 | # ::libtelegram::sendVideo # 239 | # ---------------------------------------------------------------------------- # 240 | # sendVideo: Sends a video to a chat group in Telegram # 241 | # https://core.telegram.org/bots/api#sendvideo # 242 | # ---------------------------------------------------------------------------- # 243 | proc ::libtelegram::sendVideo {chat_id video duration width height thumb caption parse_mode supports_streaming disable_notification reply_to_message_id reply_markup} { 244 | if { [ catch { 245 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendVideo -d chat_id=$chat_id -d video=$video -d duration=$duration -d width=$width -d height=$height -d thumb=$thumb -d caption=$caption -d parse_mode=$parse_mode -d supports_streaming=$supports_streaming -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 246 | } ] } { 247 | set ::libtelegram::errorMessage "libtelegram::sendVideo: cannot connect to api.telegram.com." 248 | return [set ::libtelegram::errorNumber -1] 249 | } else { 250 | if {![::libtelegram::checkValidResult]} { 251 | set ::libtelegram::errorMessage "libtelegram::sendVideo: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 252 | return $::libtelegram::errorNumber 253 | } 254 | } 255 | 256 | return [set ::libtelegram::errornumber 0] 257 | } 258 | 259 | # ---------------------------------------------------------------------------- # 260 | # ::libtelegram::sendAnimation # 261 | # ---------------------------------------------------------------------------- # 262 | # sendAnimation: Send animation files (GIF or H.264/MPEG-4 AVC video w/o sound)# 263 | # https://core.telegram.org/bots/api#sendanimation # 264 | # ---------------------------------------------------------------------------- # 265 | proc ::libtelegram::sendAnimation {chat_id animation duration width height thumb caption parse_mode supports_streaming disable_notification reply_to_message_id reply_markup} { 266 | if { [ catch { 267 | # set ::libtelegram::result [exec cat $filename | curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendAnimation -F chat_id=$chat_id -F animation=@-;type=image/gif;filename=$id.gif -F duration=$duration -F width=$width -F height=$height -F thumb=$thumb -F caption=$caption -F parse_mode=$parse_mode -F supports_streaming=$supports_streaming -F disable_notification=$disable_notification -F reply_to_message_id=$reply_to_message_id -F reply_markup=$reply_markup] 268 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendAnimation -F chat_id=$chat_id -F animation=@$animation;type=image/gif;filename=animation.gif -F duration=$duration -F width=$width -F height=$height -F thumb=$thumb -F caption=$caption -F parse_mode=$parse_mode -F supports_streaming=$supports_streaming -F disable_notification=$disable_notification -F reply_to_message_id=$reply_to_message_id -F reply_markup=$reply_markup] 269 | } ] } { 270 | set ::libtelegram::errorMessage "libtelegram::sendAnimation: cannot connect to api.telegram.com." 271 | return [set ::libtelegram::errorNumber -1] 272 | } else { 273 | if {![::libtelegram::checkValidResult]} { 274 | set ::libtelegram::errorMessage "libtelegram::sendAnimation: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 275 | return $::libtelegram::errorNumber 276 | } 277 | } 278 | 279 | return [set ::libtelegram::errornumber 0] 280 | } 281 | 282 | # ---------------------------------------------------------------------------- # 283 | # ::libtelegram::sendVoice # 284 | # ---------------------------------------------------------------------------- # 285 | # sendVoice: Sends a playable voice message to a chat group in Telegram # 286 | # https://core.telegram.org/bots/api#sendvoice # 287 | # ---------------------------------------------------------------------------- # 288 | proc ::libtelegram::sendVoice {chat_id voice caption parse_mode duration disable_notification reply_to_message_id reply_markup} { 289 | if { [ catch { 290 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendVoice -d chat_id=$chat_id -d voice=$voice -d caption=$caption -d parse_mode=$parse_mode -d duration=$duration -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 291 | } ] } { 292 | set ::libtelegram::errorMessage "libtelegram::sendVoice: cannot connect to api.telegram.com." 293 | return [set ::libtelegram::errorNumber -1] 294 | } else { 295 | if {![::libtelegram::checkValidResult]} { 296 | set ::libtelegram::errorMessage "libtelegram::sendVoice: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 297 | return $::libtelegram::errorNumber 298 | } 299 | } 300 | 301 | return [set ::libtelegram::errornumber 0] 302 | } 303 | 304 | # ---------------------------------------------------------------------------- # 305 | # ::libtelegram::sendVideoNote # 306 | # ---------------------------------------------------------------------------- # 307 | # sendVideoNote: Sends a video note to a chat group in Telegram # 308 | # https://core.telegram.org/bots/api#sendvideonote # 309 | # ---------------------------------------------------------------------------- # 310 | proc ::libtelegram::sendVideoNote {chat_id media disable_notification reply_to_message_id} { 311 | if { [ catch { 312 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendVideoNote -d chat_id=$chat_id -d media=$media -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id] 313 | } ] } { 314 | set ::libtelegram::errorMessage "libtelegram::sendVideoNote: cannot connect to api.telegram.com." 315 | return [set ::libtelegram::errorNumber -1] 316 | } else { 317 | if {![::libtelegram::checkValidResult]} { 318 | set ::libtelegram::errorMessage "libtelegram::sendVideoNote: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 319 | return $::libtelegram::errorNumber 320 | } 321 | } 322 | 323 | return [set ::libtelegram::errornumber 0] 324 | } 325 | 326 | # ---------------------------------------------------------------------------- # 327 | # ::libtelegram::sendMediaGroup # 328 | # ---------------------------------------------------------------------------- # 329 | # sendMediaGroup: Sends a group of photos or videos as an album # 330 | # https://core.telegram.org/bots/api#sendmediagroup # 331 | # ---------------------------------------------------------------------------- # 332 | proc ::libtelegram::sendMediaGroup {chat_id media disable_notification reply_to_message_id} { 333 | if { [ catch { 334 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendMediaGroup -d chat_id=$chat_id -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id] 335 | } ] } { 336 | set ::libtelegram::errorMessage "libtelegram::sendMediaGroup: cannot connect to api.telegram.com." 337 | return [set ::libtelegram::errorNumber -1] 338 | } else { 339 | if {![::libtelegram::checkValidResult]} { 340 | set ::libtelegram::errorMessage "libtelegram::sendMediaGroup: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 341 | return $::libtelegram::errorNumber 342 | } 343 | } 344 | 345 | return [set ::libtelegram::errornumber 0] 346 | } 347 | 348 | # ---------------------------------------------------------------------------- # 349 | # ::libtelegram::sendLocation # 350 | # ---------------------------------------------------------------------------- # 351 | # sendLocation: Sends a location to a chat group in Telegram # 352 | # https://core.telegram.org/bots/api#sendlocation # 353 | # ---------------------------------------------------------------------------- # 354 | proc ::libtelegram::sendLocation {chat_id latitude longitude live_period disable_notification reply_to_message_id reply_markup} { 355 | if { [ catch { 356 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendLocation -d chat_id=$chat_id -d latitude=$latitude -d longitude=$longitude -d live_period=$live_period -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 357 | } ] } { 358 | set ::libtelegram::errorMessage "libtelegram::sendLocation: cannot connect to api.telegram.com." 359 | return [set ::libtelegram::errorNumber -1] 360 | } else { 361 | if {![::libtelegram::checkValidResult]} { 362 | set ::libtelegram::errorMessage "libtelegram::sendLocation: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 363 | return $::libtelegram::errorNumber 364 | } 365 | } 366 | 367 | return [set ::libtelegram::errornumber 0] 368 | } 369 | 370 | # ---------------------------------------------------------------------------- # 371 | # ::libtelegram::sendVenue # 372 | # ---------------------------------------------------------------------------- # 373 | # Sends a venue to a chat group in Telegram # 374 | # https://core.telegram.org/bots/api#sendvenue # 375 | # ---------------------------------------------------------------------------- # 376 | proc ::libtelegram::sendVenue {chat_id latitude longitude title address foursquare_id foursquare_type disable_notification reply_to_message_id reply_markup} { 377 | if { [ catch { 378 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendVenue -d chat_id=$chat_id -d latitude=$latitude -d longitude=$longitude -d title=$title -d address=$address -d foursquare_id=$foursquare_id -d foursquare_type=$foursquare_type -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 379 | } ] } { 380 | set ::libtelegram::errorMessage "libtelegram::sendVenue: cannot connect to api.telegram.com." 381 | return [set ::libtelegram::errorNumber -1] 382 | } else { 383 | if {![::libtelegram::checkValidResult]} { 384 | set ::libtelegram::errorMessage "libtelegram::sendVenue: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 385 | return $::libtelegram::errorNumber 386 | } 387 | } 388 | 389 | return [set ::libtelegram::errornumber 0] 390 | } 391 | 392 | # ---------------------------------------------------------------------------- # 393 | # ::libtelegram::sendContact # 394 | # ---------------------------------------------------------------------------- # 395 | # Sends a contact to a chat group in Telegram # 396 | # https://core.telegram.org/bots/api#sendcontact # 397 | # ---------------------------------------------------------------------------- # 398 | proc ::libtelegram::sendContact {chat_id phone_number first_name last_name vcard disable_notification reply_to_message_id reply_markup} { 399 | if { [ catch { 400 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendContact -d chat_id=$chat_id -d phone_number=$phone_number -d first_name=$first_name -d last_name=$last_name -d vcard=$vcard -d disable_notification=$disable_notification -d reply_to_message_id=$reply_to_message_id -d reply_markup=$reply_markup] 401 | } ] } { 402 | set ::libtelegram::errorMessage "libtelegram::sendContact: cannot connect to api.telegram.com." 403 | return [set ::libtelegram::errorNumber -1] 404 | } else { 405 | if {![::libtelegram::checkValidResult]} { 406 | set ::libtelegram::errorMessage "libtelegram::sendContact: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 407 | return $::libtelegram::errorNumber 408 | } 409 | } 410 | 411 | return [set ::libtelegram::errornumber 0] 412 | } 413 | 414 | # ---------------------------------------------------------------------------- # 415 | # ::libtelegram::sendChatAction # 416 | # ---------------------------------------------------------------------------- # 417 | # Changes the bot's status in Telegram # 418 | # https://core.telegram.org/bots/api#sendChatAction # 419 | # ---------------------------------------------------------------------------- # 420 | proc ::libtelegram::sendChatAction {chat_id action} { 421 | if { [ catch { 422 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/sendChatAction -d chat_id=$chat_id -d action=$action] 423 | } ] } { 424 | set ::libtelegram::errorMessage "libtelegram::sendChatAction: cannot connect to api.telegram.com." 425 | return [set ::libtelegram::errorNumber -1] 426 | } else { 427 | if {![::libtelegram::checkValidResult]} { 428 | set ::libtelegram::errorMessage "libtelegram::sendChatAction: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 429 | return $::libtelegram::errorNumber 430 | } 431 | } 432 | 433 | return [set ::libtelegram::errornumber 0] 434 | } 435 | 436 | # ---------------------------------------------------------------------------- # 437 | # ::libtelegram::getUserProfilePhotos # 438 | # ---------------------------------------------------------------------------- # 439 | # Changes the bot's status in Telegram # 440 | # https://core.telegram.org/bots/api#getuserprofilephotos # 441 | # ---------------------------------------------------------------------------- # 442 | proc ::libtelegram::getUserProfilePhotos {user_id offset limit} { 443 | if { [ catch { 444 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getUserProfilePhotos -d user_id=$user_id -d offset=$offset -d limit=$limit] 445 | } ] } { 446 | set ::libtelegram::errorMessage "libtelegram::getUserProfilePhotos: cannot connect to api.telegram.com." 447 | return [set ::libtelegram::errorNumber -1] 448 | } else { 449 | if {![::libtelegram::checkValidResult]} { 450 | set ::libtelegram::errorMessage "libtelegram::getUserProfilePhotos: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 451 | return $::libtelegram::errorNumber 452 | } 453 | } 454 | 455 | return [set ::libtelegram::errornumber 0] 456 | } 457 | 458 | # ---------------------------------------------------------------------------- # 459 | # ::libtelegram::getFile # 460 | # ---------------------------------------------------------------------------- # 461 | # Changes the bot's status in Telegram # 462 | # https://core.telegram.org/bots/api#getfile # 463 | # ---------------------------------------------------------------------------- # 464 | proc ::libtelegram::getFile {file_id} { 465 | if { [ catch { 466 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getFile -d file_id=$file_id] 467 | } ] } { 468 | set ::libtelegram::errorMessage "libtelegram::getFile: cannot connect to api.telegram.com." 469 | return [set ::libtelegram::errorNumber -1] 470 | } else { 471 | if {![::libtelegram::checkValidResult]} { 472 | set ::libtelegram::errorMessage "libtelegram::getFile: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 473 | return $::libtelegram::errorNumber 474 | } 475 | } 476 | 477 | return [set ::libtelegram::errornumber 0] 478 | } 479 | 480 | # ---------------------------------------------------------------------------- # 481 | # ::libtelegram::kickChatMember # 482 | # ---------------------------------------------------------------------------- # 483 | # Kicks an user from a chat group or channel in Telegram # 484 | # https://core.telegram.org/bots/api#kickchatmember # 485 | # ---------------------------------------------------------------------------- # 486 | proc ::libtelegram::kickChatMember {chat_id user_id until_date} { 487 | if { [ catch { 488 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/kickChatMember -d chat_id=$chat_id -d user_id=$user_id -d until_date=$until_date] 489 | } ] } { 490 | set ::libtelegram::errorMessage "libtelegram::kickChatMember: cannot connect to api.telegram.com." 491 | return [set ::libtelegram::errorNumber -1] 492 | } else { 493 | if {![::libtelegram::checkValidResult]} { 494 | set ::libtelegram::errorMessage "libtelegram::kickChatMember: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 495 | return $::libtelegram::errorNumber 496 | } 497 | } 498 | 499 | return [set ::libtelegram::errornumber 0] 500 | } 501 | 502 | # ---------------------------------------------------------------------------- # 503 | # ::libtelegram::unbanChatMember # 504 | # ---------------------------------------------------------------------------- # 505 | # Unbans a previously kicked user from a chat group or channel in Telegram # 506 | # https://core.telegram.org/bots/api#unbanchatmember # 507 | # ---------------------------------------------------------------------------- # 508 | proc ::libtelegram::unbanChatMember {chat_id user_id} { 509 | if { [ catch { 510 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/unbanChatMember -d chat_id=$chat_id -d user_id=$user_id] 511 | } ] } { 512 | set ::libtelegram::errorMessage "libtelegram::unbanChatMember: cannot connect to api.telegram.com." 513 | return [set ::libtelegram::errorNumber -1] 514 | } else { 515 | if {![::libtelegram::checkValidResult]} { 516 | set ::libtelegram::errorMessage "libtelegram::unbanChatMember: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 517 | return $::libtelegram::errorNumber 518 | } 519 | } 520 | 521 | return [set ::libtelegram::errornumber 0] 522 | } 523 | 524 | # ---------------------------------------------------------------------------- # 525 | # ::libtelegram::restrictChatMember # 526 | # ---------------------------------------------------------------------------- # 527 | # Restrict a user in a chat group or channel in Telegram # 528 | # https://core.telegram.org/bots/api#restrictchatmember # 529 | # ---------------------------------------------------------------------------- # 530 | proc ::libtelegram::restrictChatMember {chat_id user_id until_date can_send_messages can_send_media_messages can_send_other_messages can_add_web_page_previews} { 531 | if { [ catch { 532 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/restrictChatMember -d chat_id=$chat_id -d user_id=$user_id -d until_date=$until_date -d can_send_messages=$can_send_messages -d can_send_media_messages=$can_send_media_messages -d can_send_other_messages=$can_send_other_messages -d can_add_web_page_previews=$can_add_web_page_previews] 533 | } ] } { 534 | set ::libtelegram::errorMessage "libtelegram::restrictChatMember: cannot connect to api.telegram.com." 535 | return [set ::libtelegram::errorNumber -1] 536 | } else { 537 | if {![::libtelegram::checkValidResult]} { 538 | set ::libtelegram::errorMessage "libtelegram::restrictChatMember: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 539 | return $::libtelegram::errorNumber 540 | } 541 | } 542 | 543 | return [set ::libtelegram::errornumber 0] 544 | } 545 | 546 | # ---------------------------------------------------------------------------- # 547 | # ::libtelegram::promoteChatMember # 548 | # ---------------------------------------------------------------------------- # 549 | # Promote or demote a user in a chat group or channel in Telegram # 550 | # https://core.telegram.org/bots/api#promotechatmember # 551 | # ---------------------------------------------------------------------------- # 552 | proc ::libtelegram::promoteChatMember {chat_id user_id can_change_info can_post_messages can_edit_messages can_delete_messages can_invite_users can_restrict_members can_pin_messages can_promote_members} { 553 | if { [ catch { 554 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/promoteChatMember -d chat_id=$chat_id -d user_id=$user_id -d can_change_info=$can_change_info -d can_post_messages=$can_post_messages -d can_edit_messages=$can_edit_messages -d can_delete_messages=$can_delete_messages -d can_invite_users=$can_invite_users -d can_restrict_members=$can_restrict_members -d can_pin_messages=$can_pin_messages -d can_promote_members=$can_promote_members] 555 | } ] } { 556 | set ::libtelegram::errorMessage "libtelegram::promoteChatMember: cannot connect to api.telegram.com." 557 | return [set ::libtelegram::errorNumber -1] 558 | } else { 559 | if {![::libtelegram::checkValidResult]} { 560 | set ::libtelegram::errorMessage "libtelegram::promoteChatMember: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 561 | return $::libtelegram::errorNumber 562 | } 563 | } 564 | 565 | return [set ::libtelegram::errornumber 0] 566 | } 567 | 568 | # ---------------------------------------------------------------------------- # 569 | # ::libtelegram::exportChatInviteLink # 570 | # ---------------------------------------------------------------------------- # 571 | # Promote or demote a user in a chat group or channel in Telegram # 572 | # https://core.telegram.org/bots/api#exportchatinvitelink # 573 | # ---------------------------------------------------------------------------- # 574 | proc ::libtelegram::exportChatInviteLink {chat_id} { 575 | if { [ catch { 576 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/exportChatInviteLink -d chat_id=$chat_id] 577 | } ] } { 578 | set ::libtelegram::errorMessage "libtelegram::exportChatInviteLink: cannot connect to api.telegram.com." 579 | return [set ::libtelegram::errorNumber -1] 580 | } else { 581 | if {![::libtelegram::checkValidResult]} { 582 | set ::libtelegram::errorMessage "libtelegram::exportChatInviteLink: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 583 | return $::libtelegram::errorNumber 584 | } 585 | } 586 | 587 | return [set ::libtelegram::errornumber 0] 588 | } 589 | 590 | # ---------------------------------------------------------------------------- # 591 | # ::libtelegram::setChatPhoto # 592 | # ---------------------------------------------------------------------------- # 593 | # Sets the channel's profile photo of a chat group or channel in Telegram # 594 | # https://core.telegram.org/bots/api#setchatphoto # 595 | # ---------------------------------------------------------------------------- # 596 | proc ::libtelegram::setChatPhoto {chat_id photo} { 597 | if { [ catch { 598 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/setChatPhoto -d chat_id=$chat_id -d photo=$photo] 599 | } ] } { 600 | set ::libtelegram::errorMessage "libtelegram::setChatPhoto: cannot connect to api.telegram.com." 601 | return [set ::libtelegram::errorNumber -1] 602 | } else { 603 | if {![::libtelegram::checkValidResult]} { 604 | set ::libtelegram::errorMessage "libtelegram::setChatPhoto: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 605 | return $::libtelegram::errorNumber 606 | } 607 | } 608 | 609 | return [set ::libtelegram::errornumber 0] 610 | } 611 | 612 | # ---------------------------------------------------------------------------- # 613 | # ::libtelegram::deleteChatPhoto # 614 | # ---------------------------------------------------------------------------- # 615 | # Delete the channel's profile photo of a chat group or channel in Telegram # 616 | # https://core.telegram.org/bots/api#deletechatphoto # 617 | # ---------------------------------------------------------------------------- # 618 | proc ::libtelegram::deleteChatPhoto {chat_id} { 619 | if { [ catch { 620 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/deleteChatPhoto -d chat_id=$chat_id] 621 | } ] } { 622 | set ::libtelegram::errorMessage "libtelegram::deleteChatPhoto: cannot connect to api.telegram.com." 623 | return [set ::libtelegram::errorNumber -1] 624 | } else { 625 | if {![::libtelegram::checkValidResult]} { 626 | set ::libtelegram::errorMessage "libtelegram::deleteChatPhoto: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 627 | return $::libtelegram::errorNumber 628 | } 629 | } 630 | 631 | return [set ::libtelegram::errornumber 0] 632 | } 633 | 634 | # ---------------------------------------------------------------------------- # 635 | # ::libtelegram::setChatTitle # 636 | # ---------------------------------------------------------------------------- # 637 | # Sets the channel's title of a chat group or channel in Telegram # 638 | # https://core.telegram.org/bots/api#setchattitle # 639 | # ---------------------------------------------------------------------------- # 640 | proc ::libtelegram::setChatTitle {chat_id title} { 641 | if { [ catch { 642 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/setChatTitle -d chat_id=$chat_id -d title=$title] 643 | } ] } { 644 | set ::libtelegram::errorMessage "libtelegram::setChatTitle: cannot connect to api.telegram.com." 645 | return [set ::libtelegram::errorNumber -1] 646 | } else { 647 | if {![::libtelegram::checkValidResult]} { 648 | set ::libtelegram::errorMessage "libtelegram::setChatTitle: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 649 | return $::libtelegram::errorNumber 650 | } 651 | } 652 | 653 | return [set ::libtelegram::errornumber 0] 654 | } 655 | 656 | # ---------------------------------------------------------------------------- # 657 | # ::libtelegram::setChatDescription # 658 | # ---------------------------------------------------------------------------- # 659 | # Sets the channel's description of a chat group or channel in Telegram # 660 | # https://core.telegram.org/bots/api#setchatdescription # 661 | # ---------------------------------------------------------------------------- # 662 | proc ::libtelegram::setChatDescription {chat_id description} { 663 | if { [ catch { 664 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/setChatDescription -d chat_id=$chat_id -d description=$description] 665 | } ] } { 666 | set ::libtelegram::errorMessage "libtelegram::setChatDescription: cannot connect to api.telegram.com." 667 | return [set ::libtelegram::errorNumber -1] 668 | } else { 669 | if {![::libtelegram::checkValidResult]} { 670 | set ::libtelegram::errorMessage "libtelegram::setChatDescription: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 671 | return $::libtelegram::errorNumber 672 | } 673 | } 674 | 675 | return [set ::libtelegram::errornumber 0] 676 | } 677 | 678 | # ---------------------------------------------------------------------------- # 679 | # ::libtelegram::pinChatMessage # 680 | # ---------------------------------------------------------------------------- # 681 | # Pin a message in a supergroup or a channel in Telegram # 682 | # https://core.telegram.org/bots/api#pinchatmessage # 683 | # ---------------------------------------------------------------------------- # 684 | proc ::libtelegram::pinChatMessage {chat_id message_id disable_notification} { 685 | if { [ catch { 686 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/pinChatMessage -d chat_id=$chat_id -d message_id=$message_id -d disable_notification=$disable_notification] 687 | } ] } { 688 | set ::libtelegram::errorMessage "libtelegram::pinChatMessage: cannot connect to api.telegram.com." 689 | return [set ::libtelegram::errorNumber -1] 690 | } else { 691 | if {![::libtelegram::checkValidResult]} { 692 | set ::libtelegram::errorMessage "libtelegram::pinChatMessage: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 693 | return $::libtelegram::errorNumber 694 | } 695 | } 696 | 697 | return [set ::libtelegram::errornumber 0] 698 | } 699 | 700 | # ---------------------------------------------------------------------------- # 701 | # ::libtelegram::unpinChatMessage # 702 | # ---------------------------------------------------------------------------- # 703 | # Unpin a message in a supergroup or a channel in Telegram # 704 | # https://core.telegram.org/bots/api#unpinchatmessage # 705 | # ---------------------------------------------------------------------------- # 706 | proc ::libtelegram::unpinChatMessage {chat_id} { 707 | if { [ catch { 708 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/unpinChatMessage -d chat_id=$chat_id] 709 | } ] } { 710 | set ::libtelegram::errorMessage "libtelegram::unpinChatMessage: cannot connect to api.telegram.com." 711 | return [set ::libtelegram::errorNumber -1] 712 | } else { 713 | if {![::libtelegram::checkValidResult]} { 714 | set ::libtelegram::errorMessage "libtelegram::unpinChatMessage: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 715 | return $::libtelegram::errorNumber 716 | } 717 | } 718 | 719 | return [set ::libtelegram::errornumber 0] 720 | } 721 | 722 | # ---------------------------------------------------------------------------- # 723 | # ::libtelegram::leaveChat # 724 | # ---------------------------------------------------------------------------- # 725 | # Use this method for your bot to leave a group, supergroup or channel # 726 | # https://core.telegram.org/bots/api#leavechat # 727 | # ---------------------------------------------------------------------------- # 728 | proc ::libtelegram::leaveChat {chat_id} { 729 | if { [ catch { 730 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/leaveChat -d chat_id=$chat_id] 731 | } ] } { 732 | set ::libtelegram::errorMessage "libtelegram::leaveChat: cannot connect to api.telegram.com." 733 | return [set ::libtelegram::errorNumber -1] 734 | } else { 735 | if {![::libtelegram::checkValidResult]} { 736 | set ::libtelegram::errorMessage "libtelegram::leaveChat: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 737 | return $::libtelegram::errorNumber 738 | } 739 | } 740 | 741 | return [set ::libtelegram::errornumber 0] 742 | } 743 | 744 | # ---------------------------------------------------------------------------- # 745 | # ::libtelegram::getChat # 746 | # ---------------------------------------------------------------------------- # 747 | # Get up to date information about the chat group in Telegram # 748 | # https://core.telegram.org/bots/api#getchat # 749 | # ---------------------------------------------------------------------------- # 750 | proc ::libtelegram::getChat {chat_id} { 751 | if { [ catch { 752 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getChat -d chat_id=$chat_id] 753 | } ] } { 754 | set ::libtelegram::errorMessage "libtelegram::getChat: cannot connect to api.telegram.com." 755 | return [set ::libtelegram::errorNumber -1] 756 | } else { 757 | if {![::libtelegram::checkValidResult]} { 758 | set ::libtelegram::errorMessage "libtelegram::getChat: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 759 | return $::libtelegram::errorNumber 760 | } 761 | } 762 | 763 | return [set ::libtelegram::errornumber 0] 764 | } 765 | 766 | # ---------------------------------------------------------------------------- # 767 | # ::libtelegram::getChatAdministrators # 768 | # ---------------------------------------------------------------------------- # 769 | # Get a list of administrators in a chat group in Telegram # 770 | # https://core.telegram.org/bots/api#getchatadministrators # 771 | # ---------------------------------------------------------------------------- # 772 | proc ::libtelegram::getChatAdministrators {chat_id} { 773 | if { [ catch { 774 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getChatAdministrators -d chat_id=$chat_id] 775 | } ] } { 776 | set ::libtelegram::errorMessage "libtelegram::getChatAdministrators: cannot connect to api.telegram.com." 777 | return [set ::libtelegram::errorNumber -1] 778 | } else { 779 | if {![::libtelegram::checkValidResult]} { 780 | set ::libtelegram::errorMessage "libtelegram::getChatAdministrators: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 781 | return $::libtelegram::errorNumber 782 | } 783 | } 784 | 785 | return [set ::libtelegram::errornumber 0] 786 | } 787 | 788 | # ---------------------------------------------------------------------------- # 789 | # ::libtelegram::getChatMembersCount # 790 | # ---------------------------------------------------------------------------- # 791 | # Get the number of members in a chat group in Telegram # 792 | # https://core.telegram.org/bots/api#getchatmemberscount # 793 | # ---------------------------------------------------------------------------- # 794 | proc ::libtelegram::getChatMembersCount {chat_id} { 795 | if { [ catch { 796 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getChatMembersCount -d chat_id=$chat_id] 797 | } ] } { 798 | set ::libtelegram::errorMessage "libtelegram::getChatMembersCount: cannot connect to api.telegram.com." 799 | return [set ::libtelegram::errorNumber -1] 800 | } else { 801 | if {![::libtelegram::checkValidResult]} { 802 | set ::libtelegram::errorMessage "libtelegram::getChatMembersCount: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 803 | return $::libtelegram::errorNumber 804 | } 805 | } 806 | 807 | return [set ::libtelegram::errornumber 0] 808 | } 809 | 810 | # ---------------------------------------------------------------------------- # 811 | # ::libtelegram::getChatMember # 812 | # ---------------------------------------------------------------------------- # 813 | # Get information about a member of a chat group in Telegram # 814 | # https://core.telegram.org/bots/api#getchatmember # 815 | # ---------------------------------------------------------------------------- # 816 | proc ::libtelegram::getChatMember {chat_id user_id} { 817 | if { [ catch { 818 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/getChatMember -d chat_id=$chat_id -d user_id=$user_id] 819 | } ] } { 820 | set ::libtelegram::errorMessage "libtelegram::getChatMember: cannot connect to api.telegram.com." 821 | return [set ::libtelegram::errorNumber -1] 822 | } else { 823 | if {![::libtelegram::checkValidResult]} { 824 | set ::libtelegram::errorMessage "libtelegram::getChatMember: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 825 | return $::libtelegram::errorNumber 826 | } 827 | } 828 | 829 | return [set ::libtelegram::errornumber 0] 830 | } 831 | 832 | # ---------------------------------------------------------------------------- # 833 | # ::libtelegram::setChatStickerSet # 834 | # ---------------------------------------------------------------------------- # 835 | # Set a new group sticker set for a supergroup in Telegram # 836 | # https://core.telegram.org/bots/api#setchatstickerset # 837 | # ---------------------------------------------------------------------------- # 838 | proc ::libtelegram::setChatStickerSet {chat_id sticker_set_name} { 839 | if { [ catch { 840 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/setChatStickerSet -d chat_id=$chat_id -d sticker_set_name=$sticker_set_name] 841 | } ] } { 842 | set ::libtelegram::errorMessage "libtelegram::setChatStickerSet: cannot connect to api.telegram.com." 843 | return [set ::libtelegram::errorNumber -1] 844 | } else { 845 | if {![::libtelegram::checkValidResult]} { 846 | set ::libtelegram::errorMessage "libtelegram::setChatStickerSet: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 847 | return $::libtelegram::errorNumber 848 | } 849 | } 850 | 851 | return [set ::libtelegram::errornumber 0] 852 | } 853 | 854 | # ---------------------------------------------------------------------------- # 855 | # ::libtelegram::deleteChatStickerSet # 856 | # ---------------------------------------------------------------------------- # 857 | # Delete a group sticker set from a supergroup in Telegram # 858 | # https://core.telegram.org/bots/api#deletechatstickerset # 859 | # ---------------------------------------------------------------------------- # 860 | proc ::libtelegram::deleteChatStickerSet {chat_id sticker_set_name} { 861 | if { [ catch { 862 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/deleteChatStickerSet -d chat_id=$chat_id -d sticker_set_name=$sticker_set_name] 863 | } ] } { 864 | set ::libtelegram::errorMessage "libtelegram::deleteChatStickerSet: cannot connect to api.telegram.com." 865 | return [set ::libtelegram::errorNumber -1] 866 | } else { 867 | if {![::libtelegram::checkValidResult]} { 868 | set ::libtelegram::errorMessage "libtelegram::deleteChatStickerSet: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 869 | return $::libtelegram::errorNumber 870 | } 871 | } 872 | 873 | return [set ::libtelegram::errornumber 0] 874 | } 875 | 876 | # ---------------------------------------------------------------------------- # 877 | # ::libtelegram::editMessageText # 878 | # ---------------------------------------------------------------------------- # 879 | # Edit text and game messages sent by the bot or via the bot (for inline bots) # 880 | # https://core.telegram.org/bots/api#editMessageText # 881 | # ---------------------------------------------------------------------------- # 882 | proc ::libtelegram::editMessageText {chat_id message_id inline_message_id text parse_mode disable_web_page_preview reply_markup} { 883 | if { [ catch { 884 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/pinChatMessage -d chat_id=$chat_id -d message_id=$message_id -d inline_message_id=$inline_message_id -d text=$text -d parse_mode=$parse_mode -d disable_web_page_preview=$disable_web_page_preview -d reply_markup=$reply_markup] 885 | } ] } { 886 | set ::libtelegram::errorMessage "libtelegram::editMessageText: cannot connect to api.telegram.com." 887 | return [set ::libtelegram::errorNumber -1] 888 | } else { 889 | if {![::libtelegram::checkValidResult]} { 890 | set ::libtelegram::errorMessage "libtelegram::editMessageText: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 891 | return $::libtelegram::errorNumber 892 | } 893 | } 894 | 895 | return [set ::libtelegram::errornumber 0] 896 | } 897 | 898 | # ---------------------------------------------------------------------------- # 899 | # ::libtelegram::editMessageCaption # 900 | # ---------------------------------------------------------------------------- # 901 | # Edit captions of messages sent by the bot or via the bot (for inline bots) # 902 | # https://core.telegram.org/bots/api#editMessageCaption # 903 | # ---------------------------------------------------------------------------- # 904 | proc ::libtelegram::editMessageCaption {chat_id message_id inline_message_id caption parse_mode reply_markup} { 905 | if { [ catch { 906 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/pinChatMessage -d chat_id=$chat_id -d message_id=$message_id -d inline_message_id=$inline_message_id -d caption=$caption -d parse_mode=$parse_mode -d reply_markup=$reply_markup] 907 | } ] } { 908 | set ::libtelegram::errorMessage "libtelegram::editMessageCaption: cannot connect to api.telegram.com." 909 | return [set ::libtelegram::errorNumber -1] 910 | } else { 911 | if {![::libtelegram::checkValidResult]} { 912 | set ::libtelegram::errorMessage "libtelegram::editMessageCaption: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 913 | return $::libtelegram::errorNumber 914 | } 915 | } 916 | 917 | return [set ::libtelegram::errornumber 0] 918 | } 919 | 920 | # ---------------------------------------------------------------------------- # 921 | # ::libtelegram::editMessageMedia # 922 | # ---------------------------------------------------------------------------- # 923 | # Edit audio, document, photo, or video messages # 924 | # https://core.telegram.org/bots/api#editMessageMedia # 925 | # ---------------------------------------------------------------------------- # 926 | proc ::libtelegram::editMessageMedia {chat_id message_id inline_message_id media reply_markup} { 927 | if { [ catch { 928 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/editMessageMedia -d chat_id=$chat_id -d message_id=$message_id -d inline_message_id=$inline_message_id -d media=$media -d reply_markup=$reply_markup] 929 | } ] } { 930 | set ::libtelegram::errorMessage "libtelegram::editMessageMedia: cannot connect to api.telegram.com." 931 | return [set ::libtelegram::errorNumber -1] 932 | } else { 933 | if {![::libtelegram::checkValidResult]} { 934 | set ::libtelegram::errorMessage "libtelegram::editMessageMedia: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 935 | return $::libtelegram::errorNumber 936 | } 937 | } 938 | 939 | return [set ::libtelegram::errornumber 0] 940 | } 941 | 942 | # ---------------------------------------------------------------------------- # 943 | # ::libtelegram::editMessageReplyMarkup # 944 | # ---------------------------------------------------------------------------- # 945 | # Edit only the reply markup of messages sent by the bot or via the bot # 946 | # https://core.telegram.org/bots/api#editMessageReplyMarkup # 947 | # ---------------------------------------------------------------------------- # 948 | proc ::libtelegram::editMessageReplyMarkup {chat_id message_id inline_message_id reply_markup} { 949 | if { [ catch { 950 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/editMessageReplyMarkup -d chat_id=$chat_id -d message_id=$message_id -d inline_message_id=$inline_message_id -d reply_markup=$reply_markup] 951 | } ] } { 952 | set ::libtelegram::errorMessage "libtelegram::editMessageReplyMarkup: cannot connect to api.telegram.com." 953 | return [set ::libtelegram::errorNumber -1] 954 | } else { 955 | if {![::libtelegram::checkValidResult]} { 956 | set ::libtelegram::errorMessage "libtelegram::editMessageReplyMarkup: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 957 | return $::libtelegram::errorNumber 958 | } 959 | } 960 | 961 | return [set ::libtelegram::errornumber 0] 962 | } 963 | 964 | # ---------------------------------------------------------------------------- # 965 | # ::libtelegram::deleteMessage # 966 | # ---------------------------------------------------------------------------- # 967 | # Deletes a message, including service messages. # 968 | # https://core.telegram.org/bots/api#deleteMessage # 969 | # ---------------------------------------------------------------------------- # 970 | proc ::libtelegram::deleteMessage {chat_id message_id} { 971 | if { [ catch { 972 | set ::libtelegram::result [exec curl --tlsv1.2 -s -X POST https://api.telegram.org/bot$::libtelegram::bot_id:$::libtelegram::bot_token/deleteMessage -d chat_id=$chat_id -d message_id=$message_id] 973 | } ] } { 974 | set ::libtelegram::errorMessage "libtelegram::deleteMessage: cannot connect to api.telegram.com." 975 | return [set ::libtelegram::errorNumber -1] 976 | } else { 977 | if {![::libtelegram::checkValidResult]} { 978 | set ::libtelegram::errorMessage "libtelegram::deleteMessage: $::libtelegram::errorNumber - $::libtelegram::errorMessage" 979 | return $::libtelegram::errorNumber 980 | } 981 | } 982 | 983 | return [set ::libtelegram::errornumber 0] 984 | } 985 | 986 | # ---------------------------------------------------------------------------- # 987 | # ::libtelegram::downloadFile # 988 | # ---------------------------------------------------------------------------- # 989 | # Download a Telegram attachment # 990 | # https://core.telegram.org/bots/api#getfile # 991 | # ---------------------------------------------------------------------------- # 992 | proc ::libtelegram::downloadFile {file_path filename} { 993 | # Check if we can open a temp file 994 | if { [catch {open $filename w} fo] } { 995 | # Probably no need to close and delete the file, but we'll do it anyways just to be sure 996 | close $fo 997 | file delete -force $filename 998 | putlog "::libtelegram::downloadFile: cannot create temp file $filename" 999 | return -1 1000 | } else { 1001 | fconfigure $fo -translation binary 1002 | if { [ catch { 1003 | puts -nonewline $fo [exec curl --tlsv1.2 --max-filesize $::libtelegram::max_file_size --range 0-$::libtelegram::max_file_size --silent --request GET https://api.telegram.org/file/bot$::libtelegram::bot_id:$::libtelegram::bot_token/$file_path] 1004 | } ] } { 1005 | close $fo 1006 | file delete -force $filename 1007 | putlog "Telegram-API: cannot connect to api.telegram.com for downloading $file_path" 1008 | return -2 1009 | } 1010 | } 1011 | close $fo 1012 | return 0 1013 | } 1014 | 1015 | proc ::libtelegram::checkValidResult {} { 1016 | if {[::libjson::getValue $::libtelegram::result ".ok"] eq "false"} { 1017 | # Set error number and message to the values received from the API servers 1018 | set ::libtelegram::errorNumber [::libjson::getValue $::libtelegram::result ".error_code"] 1019 | set ::libtelegram::errorMessage [::libjson::getValue $::libtelegram::result ".description"] 1020 | return false 1021 | } else { 1022 | if {[::libjson::getValue $::libtelegram::result ".ok"] ne "true"} { 1023 | # Probably got a HTML response, like 502 Bad Gateway 1024 | if {[set titlestart [string first "" $::libtelegram::result $titlestart] 1031 | set titleend [string first "" $::libtelegram::result $titlestart] 1032 | set ::libtelegram::errorNumber -1 1033 | set ::libtelegram::errorMessage [string range $::libtelegram::result $titlestart+1 $titleend-1] 1034 | return false 1035 | } 1036 | } else { 1037 | return true 1038 | } 1039 | } 1040 | } 1041 | -------------------------------------------------------------------------------- /modules/IRChelper.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # IRC helper module for Eggdrop with the Telegram-API module v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Shows information about an IRC channel # 9 | # ---------------------------------------------------------------------------- # 10 | proc ::telegram::ircChannelInfo {from_id chat_id msgid channel message parameter_start} { 11 | global serveraddress 12 | 13 | set response "[::msgcat::mc MSG_BOT_IRCINFO "$serveraddress/$channel" "$channel" "[topic $channel]" "[getchanmode $channel]"]" 14 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 15 | putchan $channel "[strip_html $response]" 16 | 17 | # Return success 18 | return 0 19 | } 20 | 21 | # ---------------------------------------------------------------------------- # 22 | # Shows detailed information about an user on IRC # 23 | # ---------------------------------------------------------------------------- # 24 | proc ::telegram::ircuser {from_id chat_id msgid channel message parameter_start} { 25 | global serveraddress 26 | 27 | set handle [string trim [string range $message $parameter_start end]] 28 | 29 | if {$handle != ""} { 30 | if {[onchan $handle $channel]} { 31 | set online_since [clock format [getchanjoin $handle $channel] -format $::telegram::timeformat] 32 | set response "[::msgcat::mc MSG_BOT_IRCUSER "$handle" "$online_since" "$serveraddress/$channel" "$channel" "[getchanhost $handle $channel]"]" 33 | } else { 34 | set response "[::msgcat::mc MSG_BOT_IRCUSERUNKNOWN "$handle" "$serveraddress/$channel" "$channel"]" 35 | } 36 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 37 | putchan $channel "[strip_html $response]" 38 | 39 | # Return success 40 | return 0 41 | } else { 42 | # Return an error, so the help message will be shown 43 | return -1 44 | } 45 | } 46 | 47 | # ---------------------------------------------------------------------------- # 48 | # Shows all users on an IRC channel # 49 | # ---------------------------------------------------------------------------- # 50 | proc ::telegram::ircusers {from_id chat_id msgid channel message parameter_start} { 51 | global serveraddress 52 | 53 | set response "[::msgcat::mc MSG_BOT_IRCUSERS "$serveraddress/$channel" "$channel" "[string map {" " "\n"} [chanlist $channel]]"]" 54 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 55 | putchan $channel "[strip_html $response]" 56 | 57 | # Return success 58 | return 0 59 | } 60 | 61 | # ---------------------------------------------------------------------------- # 62 | # Kicks an user on an IRC channel # 63 | # ---------------------------------------------------------------------------- # 64 | proc ::telegram::ircKick {from_id chat_id msgid channel message parameter_start} { 65 | global serveraddress 66 | 67 | set handle [string trim [string range $message $parameter_start end]] 68 | 69 | # Check if the Telegram user requesting the unban is logged in 70 | if {[set irchandle [::telegram::getIRCNickFromTelegramID $from_id]] != -1} { 71 | # Check if the user is on the IRC channel 72 | if {[onchan $handle $channel]} { 73 | # Check if the bot has enough privileges to perform the kick 74 | if {[botisop $channel] || [botishalfop $channel]} { 75 | foreach {tg_chat_id tg_channel} [array get ::telegram::tg_channels] { 76 | if {$chat_id eq $tg_chat_id} { 77 | putkick $tg_channel $handle [::msgcat::mc MSG_BOT_IRCKICKUSER] 78 | } 79 | } 80 | # Return success 81 | return 0 82 | } else { 83 | set response "[::msgcat::mc MSG_BOT_GOTNOPRIVS $::telegram::irc_bot_nickname]" 84 | } 85 | } else { 86 | set response "[::msgcat::mc MSG_BOT_IRCUSERUNKNOWN "$handle" "$serveraddress/$channel" "$channel"]" 87 | } 88 | } else { 89 | set response "[::msgcat::mc MSG_BOT_NOTLOGGEDIN]" 90 | } 91 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 92 | putchan $channel "[strip_html $response]" 93 | 94 | return 0 95 | } 96 | 97 | # ---------------------------------------------------------------------------- # 98 | # Bans an user on an IRC channel # 99 | # ---------------------------------------------------------------------------- # 100 | proc ::telegram::ircBan {from_id chat_id msgid channel message parameter_start} { 101 | global serveraddress 102 | 103 | set handle [string trim [string range $message $parameter_start end]] 104 | 105 | # Check if the Telegram user requesting the unban is logged in 106 | if {[set irchandle [::telegram::getIRCNickFromTelegramID $from_id]] != -1} { 107 | # Check if the user is on the IRC channel 108 | if {[onchan $handle $channel]} { 109 | # Check if the bot has enough privileges to perform the ban 110 | if {[botisop $channel] || [botishalfop $channel]} { 111 | foreach {tg_chat_id tg_channel} [array get ::telegram::tg_channels] { 112 | if {$chat_id eq $tg_chat_id} { 113 | newchanban $tg_channel "$handle![getchanhost $handle $channel]" $::telegram::irc_bot_nickname [::msgcat::mc MSG_IRCBANUSER] 114 | } 115 | } 116 | # Return success 117 | return 0 118 | } else { 119 | set response "[::msgcat::mc MSG_BOT_GOTNOPRIVS $::telegram::irc_bot_nickname]" 120 | } 121 | } else { 122 | set response "[::msgcat::mc MSG_BOT_IRCUSERUNKNOWN "$handle" "$serveraddress/$channel" "$channel"]" 123 | } 124 | } else { 125 | set response "[::msgcat::mc MSG_BOT_NOTLOGGEDIN]" 126 | } 127 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 128 | putchan $channel "[strip_html $response]" 129 | 130 | return 0 131 | } 132 | 133 | # ---------------------------------------------------------------------------- # 134 | # Unbans an user on an IRC channel # 135 | # ---------------------------------------------------------------------------- # 136 | proc ::telegram::ircUnban {from_id chat_id msgid channel message parameter_start} { 137 | set result 0 138 | set handle [string trim [string range $message $parameter_start end]] 139 | 140 | # Check if the Telegram user requesting the unban is logged in 141 | if {[set irchandle [::telegram::getIRCNickFromTelegramID $from_id]] != -1} { 142 | # Check if the bot has enough privileges to perform the unban 143 | if {[botisop $channel] || [botishalfop $channel]} { 144 | foreach {tg_chat_id tg_channel} [array get ::telegram::tg_channels] { 145 | if {$chat_id eq $tg_chat_id} { 146 | if {[killchanban $tg_channel $handle] eq 0} { 147 | set result -1 148 | } 149 | } 150 | } 151 | # Return success 152 | return $result 153 | } else { 154 | set response "[::msgcat::mc MSG_BOT_GOTNOPRIVS $::telegram::irc_bot_nickname]" 155 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 156 | putchan $channel "[strip_html $response]" 157 | 158 | return 0 159 | } 160 | } else { 161 | set response "[::msgcat::mc MSG_BOT_NOTLOGGEDIN]" 162 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 163 | putchan $channel "[strip_html $response]" 164 | 165 | return 0 166 | } 167 | } 168 | 169 | # ---------------------------------------------------------------------------- # 170 | # Change the channel mode on an IRC channel # 171 | # ---------------------------------------------------------------------------- # 172 | proc ::telegram::ircSetMode {from_id chat_id msgid channel message parameter_start} { 173 | global serveraddress 174 | 175 | set mode [string trim [string range $message $parameter_start end]] 176 | 177 | # Check if the Telegram user requesting the unban is logged in 178 | if {[set irchandle [::telegram::getIRCNickFromTelegramID $from_id]] != -1} { 179 | # Check if the bot has enough privileges to perform the ban 180 | if {[botisop $channel] || [botishalfop $channel]} { 181 | foreach {tg_chat_id tg_channel} [array get ::telegram::tg_channels] { 182 | if {$chat_id eq $tg_chat_id} { 183 | pushmode $tg_channel $mode 184 | flushmode $tg_channel 185 | } 186 | } 187 | # Return success 188 | return 0 189 | } else { 190 | set response "[::msgcat::mc MSG_BOT_GOTNOPRIVS $::telegram::irc_bot_nickname]" 191 | } 192 | } else { 193 | set response "[::msgcat::mc MSG_BOT_NOTLOGGEDIN]" 194 | } 195 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 196 | putchan $channel "[strip_html $response]" 197 | 198 | return 0 199 | } 200 | 201 | ::telegram::addPublicTgCommand ircinfo ::telegram::ircChannelInfo "[::msgcat::mc MSG_BOT_IRCINFO_HELP]" 202 | ::telegram::addPublicTgCommand ircuser ::telegram::ircuser "[::msgcat::mc MSG_BOT_IRCUSER_HELP]" 203 | ::telegram::addPublicTgCommand ircusers ::telegram::ircusers "[::msgcat::mc MSG_BOT_IRCUSERS_HELP]" 204 | ::telegram::addPublicTgCommand irckick ::telegram::ircKick "[::msgcat::mc MSG_BOT_IRCKICK_HELP]" 205 | ::telegram::addPublicTgCommand ircban ::telegram::ircBan "[::msgcat::mc MSG_BOT_IRCBAN_HELP]" 206 | ::telegram::addPublicTgCommand ircunban ::telegram::ircUnban "[::msgcat::mc MSG_BOT_IRCUNBAN_HELP]" 207 | ::telegram::addPublicTgCommand ircsetmode ::telegram::ircSetMode "[::msgcat::mc MSG_BOT_IRCSETMODE_HELP]" 208 | -------------------------------------------------------------------------------- /modules/ImageSearch.conf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Image Search module for Eggdrop with the Telegram-API module v20180803 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | # Safe Search: -2 for 'Off', -1 for 'Average', 0 for 'On' 12 | 13 | set ::ImageSearch::safesearch 0 14 | set ::ImageSearch::locale nl_NL 15 | set ::ImageSearch::GiphyAPIkey dc6zaTOxFJmzC 16 | 17 | ::msgcat::mcset de MSG_GIFSEARCH_HELP ": Suche nach einem Animiertes GIF, das zu passt." 18 | ::msgcat::mcset de MSG_IMAGESEARCH_NOTFOUND "Nights gefunden :-(" 19 | ::msgcat::mcset de MSG_IMAGESEARCH_HELP ": Suche nach einem Bild, das zu passt." 20 | ::msgcat::mcset de MSG_IMAGESEARCH_ERROR "Qwant API hat eine Fehlermeldung ausgegeben result=%1\$s error_code=%2\$s@." 21 | ::msgcat::mcset en MSG_IMAGESEARCH_HELP ": Search for an animated GIF matching ." 22 | ::msgcat::mcset en MSG_IMAGESEARCH_NOTFOUND "Nothing found :-(" 23 | ::msgcat::mcset en MSG_IMAGESEARCH_HELP ": Search for an image matching ." 24 | ::msgcat::mcset en MSG_IMAGESEARCH_ERROR "Qwant API returned with an error result=%1\$s error_code=%2\$s@." 25 | ::msgcat::mcset nl MSG_IMAGESEARCH_HELP ": Zoek naar een animated GIF die overeenkomt met ." 26 | ::msgcat::mcset nl MSG_IMAGESEARCH_NOTFOUND "Niets gevonden :-(" 27 | ::msgcat::mcset nl MSG_IMAGESEARCH_HELP ": Zoek naar een afbeelding die overeenkomt met ." 28 | ::msgcat::mcset nl MSG_IMAGESEARCH_ERROR "Qwant API heeft een foutmelding teruggegeven result=%1\$s error_code=%2\$s@." 29 | -------------------------------------------------------------------------------- /modules/ImageSearch.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Image Search module for Eggdrop with the Telegram-API module v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | namespace eval ImageSearch {} 12 | source "[file join [file dirname [info script]] ImageSearch.conf]" 13 | 14 | # ---------------------------------------------------------------------------- # 15 | # Image Search procedures # 16 | # ---------------------------------------------------------------------------- # 17 | # Search an image on Qwant # 18 | # ---------------------------------------------------------------------------- # 19 | 20 | proc ::ImageSearch::getImage {from_id chat_id msgid channel message parameter_start} { 21 | if {[set imagequery [string trim [string range $message $parameter_start end]]] ne ""} { 22 | if { [ catch { 23 | # set imgresult [exec curl --tlsv1.2 -s -X POST https://api.duckduckgo.com/ -d kah=nl-nl -d kl=$s_region -d kad=$s_language -d kp=$s_safesearch -d q=$imagequery] 24 | # set imgresult [exec curl --tlsv1.2 -s -X GET https://api.duckduckgo.com/?kah=nl-nl&kl=$s_region&kad=$s_language&kp=$s_safesearch&q=$imagequery] 25 | set imgresult [exec curl --tlsv1.2 -s --header "User-Agent: Mozilla/5.0" -X GET https://api.qwant.com/api/search/ia -d t=images -d count=1 -d offset=1 -d safesearch=$::ImageSearch::safesearch -d locale=$::ImageSearch::locale -d q=$imagequery -d t=all] 26 | } ] } { 27 | putlog "::ImageSearch::getImage: cannot connect to api.qwant.com." 28 | set imgresult "" 29 | } 30 | 31 | if {[set status [::libjson::getValue $imgresult ".status//empty"]] ne "success"} { 32 | set error_code [::libjson::getValue $imgresult ".data.error_code//empty"] 33 | set reply [::msgcat::mc MSG_IMAGESEARCH_ERROR "$status" "$error_code"] 34 | ::libtelegram::sendMessage $chat_id "$reply" "html" false $msgid "" 35 | putchan $channel "$reply" 36 | } else { 37 | set media [::libjson::getValue $imgresult ".data.result.items\[0\].data\[0\].media_fullsize//empty"] 38 | if {$media == ""} { 39 | set reply [::msgcat::mc MSG_IMAGESEARCH_NOTFOUND] 40 | ::libtelegram::sendMessage $chat_id "$reply" "html" false $msgid "" 41 | putchan $channel "$reply" 42 | } else { 43 | set title [::libjson::getValue $imgresult ".data.result.items\[0\].data\[0\].title//empty"] 44 | set url [::libjson::getValue $imgresult ".data.result.items\[0\].data\[0\].url//empty"] 45 | # Quick fix to replace HTML-entities (&xxxx;) with ? 46 | # Should really use [string map...], tDOM or htmlparse::mapEscapes 47 | set title [regsub -all {&(.|\n|\r)+?;} $title "?"] 48 | ::libtelegram::sendPhoto $chat_id "https:$media" "$title" "html" false $msgid "" 49 | putchan $channel "https:$media ($title)" 50 | } 51 | } 52 | 53 | # Return success 54 | return 0 55 | } else { 56 | # Return an error, so the help message will be shown 57 | return -1 58 | } 59 | } 60 | 61 | # ---------------------------------------------------------------------------- # 62 | # Search an animated GIF on Giphy # 63 | # ---------------------------------------------------------------------------- # 64 | 65 | proc ::ImageSearch::getGif {from_id chat_id msgid channel message parameter_start} { 66 | set max_file_size 20480000 67 | 68 | if {[set imagequery [string trim [string range $message $parameter_start end]]] ne ""} { 69 | if { [ catch { 70 | set imgresult [exec curl --tlsv1.2 -s -G https://api.giphy.com/v1/gifs/search -d api_key=$::ImageSearch::GiphyAPIkey -d q=$imagequery -d limit=1 -d rating=r] 71 | } ] } { 72 | putlog "::ImageSearch::getGif: cannot connect to api.giphy.com." 73 | return -1 74 | } 75 | 76 | if {[set meta_status [::libjson::getValue $imgresult ".meta.status//empty"]] ne "200"} { 77 | set meta_msg [::libjson::getValue $imgresult ".meta.msg//empty"] 78 | set reply [::msgcat::mc MSG_GIFSEARCH_ERROR "$meta_msg" "$meta_status"] 79 | ::libtelegram::sendMessage $chat_id "$reply" "html" false $msgid "" 80 | putchan $channel "$reply" 81 | } else { 82 | if {[set count [::libjson::getValue $imgresult ".pagination.count//empty"]] ne "1"} { 83 | set reply [::msgcat::mc MSG_IMAGESEARCH_NOTFOUND] 84 | ::libtelegram::sendMessage $chat_id "$reply" "html" false $msgid "" 85 | putchan $channel "$reply" 86 | } else { 87 | set tmpfile "[file join /tmp [::libjson::getValue $imgresult ".data\[0\].id//empty"]].gif" 88 | set url [::libjson::getValue $imgresult ".data\[0\].url//empty"] 89 | set title [::libjson::getValue $imgresult ".data\[0\].title//empty"] 90 | set thumb [::libjson::getValue $imgresult ".data\[0\].images.original_still//empty"] 91 | set width [::libjson::getValue $imgresult ".data\[0\].images.original_still.width//empty"] 92 | set height [::libjson::getValue $imgresult ".data\[0\].images.original_still.height//empty"] 93 | set gifurl "[string map {https://giphy.com/gifs/ https://i.giphy.com/} $url].gif" 94 | set thumburl "[string map {https://giphy.com/gifs/ https://i.giphy.com/media/} $url]/giphy_s.gif" 95 | if { [ catch { 96 | set result [exec curl --tlsv1.2 --max-filesize $max_file_size --range 0-$max_file_size --silent --output $tmpfile --request GET $gifurl] 97 | } ] } { 98 | putlog "::ImageSearch::getGif: cannot download GIF file." 99 | return -1 100 | } 101 | ::libtelegram::sendAnimation $chat_id "$tmpfile" "" "$width" "$height" "$thumburl" "Giphy: $title" "html" false false $msgid "" 102 | file delete -force $tmpfile 103 | putchan $channel "$url (Giphy: $title)" 104 | } 105 | } 106 | 107 | # Return success 108 | return 0 109 | } else { 110 | # Return an error, so the help message will be shown 111 | return -1 112 | } 113 | } 114 | 115 | ::telegram::addPublicTgCommand get ::ImageSearch::getImage "[::msgcat::mc MSG_IMAGESEARCH_HELP]" 116 | ::telegram::addPublicTgCommand gif ::ImageSearch::getGif "[::msgcat::mc MSG_GIFSEARCH_HELP]" 117 | -------------------------------------------------------------------------------- /modules/Locate.conf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Image Search module for Eggdrop with the Telegram-API module v20180212 # 3 | # # 4 | # written by Eelco Huininga 2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | ::msgcat::mcset de MSG_LOCATE_HELP ": Suche nach einem Ort, das zu passt." 12 | ::msgcat::mcset de MSG_LOCATE_NOTFOUND "Nichts gefunden." 13 | ::msgcat::mcset en MSG_LOCATE_HELP ": Search for location on OpenStreetMap." 14 | ::msgcat::mcset en MSG_LOCATE_NOTFOUND "Nothing found." 15 | ::msgcat::mcset nl MSG_LOCATE_HELP ": Zoek naar de locatie op OpenStreetMaps." 16 | ::msgcat::mcset nl MSG_LOCATE_NOTFOUND "Niets gevonden." 17 | -------------------------------------------------------------------------------- /modules/Locate.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Locate module for Eggdrop with the Telegram-API module v20181119 # 3 | # # 4 | # written by Eelco Huininga 2017-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | source "[file join [file dirname [info script]] Locate.conf]" 12 | 13 | # ---------------------------------------------------------------------------- # 14 | # OpenStreetMaps procedures # 15 | # ---------------------------------------------------------------------------- # 16 | # Search a location on OpenStreetMaps # 17 | # ---------------------------------------------------------------------------- # 18 | 19 | proc openstreetmaps_getLocation {from_id chat_id msgid channel message parameter_start} { 20 | if {[set locationquery [string map {" " "%20"} [string trim [string range $message $parameter_start end]]]] ne ""} { 21 | # Let the Telegram users know that we've received the bot command, and we're preparing an answer 22 | ::libtelegram::sendChatAction $chat_id "find_location" 23 | 24 | if { [ catch { 25 | set result [exec curl --tlsv1.2 -s -X GET "https://nominatim.openstreetmap.org/search?q=$locationquery&format=json&polygon=0&addressdetails=0"] 26 | } ] } { 27 | putlog "Locate.tcl: cannot connect to api.openstreetmaps.com using search method." 28 | return -1 29 | } 30 | 31 | if {[set display_name [::libjson::getValue $result ".\[0\].display_name//empty"]] eq ""} { 32 | set result "[::msgcat::mc MSG_LOCATE_NOTFOUND]" 33 | libtelegram::sendMessage $chat_id "$result" "html" false $msgid "" 34 | putchan $channel "$result" 35 | return 0 36 | } else { 37 | set lat [::libjson::getValue $result ".\[0\].lat"] 38 | set lon [::libjson::getValue $result ".\[0\].lon"] 39 | libtelegram::sendVenue $chat_id $lat $lon $locationquery $display_name "" "" false $msgid "" 40 | putchan $channel "[strip_html [::libunicode::utf82ascii $display_name]]: https://www.openstreetmap.org/#map=20/$lat/$lon" 41 | } 42 | return 0 43 | } else { 44 | return -1 45 | } 46 | } 47 | 48 | ::telegram::addPublicTgCommand locate openstreetmaps_getLocation "[::msgcat::mc MSG_LOCATE_HELP]" 49 | -------------------------------------------------------------------------------- /modules/PSN.conf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API Playstation Network module for Eggdrop v20180212 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # Messages for the PSN-module 8 | ::msgcat::mcset de MSG_PSN_RESULT "Spieler: %sLevel: %sZuletzt gespielt:1. %s2. %s3. %s" 9 | ::msgcat::mcset de MSG_PSN_NOTFOUND "Keinen data gefunden. Für diesen Benutzer ist möglicherweise das Profil privat festgelegt." 10 | ::msgcat::mcset de MSG_PSN_HELP ": Zeige das öffentliche Profil eines PlayStation Network-Benutzers." 11 | ::msgcat::mcset en MSG_PSN_RESULT "Player: %sLevel: %sRecently seen playing:1. %s2. %s3. %s" 12 | ::msgcat::mcset en MSG_PSN_NOTFOUND "No data found. This user may have their profile set to private." 13 | ::msgcat::mcset en MSG_PSN_HELP ": Show the public profile of an PlayStation Network user." 14 | ::msgcat::mcset nl MSG_PSN_RESULT "Speler: %s\%0ANiveau: %s\%0ARecent gespeelde spellen:\%0A1. %s\%0A2. %s\%0a3. %s" 15 | ::msgcat::mcset nl MSG_PSN_NOTFOUND "Geen gegevens gevonden. Deze gebruiker heeft mogelijk een privé-profiel." 16 | ::msgcat::mcset nl MSG_PSN_HELP ": Laat het publieke profiel van een PSN gebruiker zien." 17 | -------------------------------------------------------------------------------- /modules/PSN.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API Playstation Network module for Eggdrop v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | source "[file join [file dirname [info script]] PSN.conf]" 12 | 13 | # ---------------------------------------------------------------------------- # 14 | # Playstation Network procedures # 15 | # ---------------------------------------------------------------------------- # 16 | # Get player information from the PlayStation Network site # 17 | # ---------------------------------------------------------------------------- # 18 | 19 | proc psn_getPSNInfo {from_id chat_id msgid channel message parameter_start} { 20 | if {[set query [string map {" " "%20"} [string trim [string range $message $parameter_start end]]]] ne ""} { 21 | if { [ catch { 22 | set result [exec curl --tlsv1.2 -s -X GET https://my.playstation.com/$query] 23 | } ] } { 24 | putlog "PSN.tcl: cannot connect to my.playstation.com." 25 | return 1 26 | } 27 | 28 | set start [string first "\""" $result] 41 | set end [string first "<" $result [expr $start+40]] 42 | set level [string range $result [expr $start+40] $end-1] 43 | 44 | set start [string first "
" $result] 45 | set start [string first "title=\"" $result $start] 46 | set end [string first "\"" $result [expr $start+7]] 47 | set game1 [string range $result [expr $start+7] $end-1] 48 | 49 | set start [string first "
" $result $start] 50 | set start [string first "title=\"" $result $start] 51 | set end [string first "\"" $result [expr $start+7]] 52 | set game2 [string range $result [expr $start+7] $end-1] 53 | 54 | set start [string first "
" $result $start] 55 | set start [string first "title=\"" $result $start] 56 | set end [string first "\"" $result [expr $start+7]] 57 | set game3 [string range $result [expr $start+7] $end-1] 58 | 59 | set response [::msgcat::mc MSG_PSN_RESULT "$name" "$level" "$game1" "$game2" "$game3"] 60 | # set response "Player: $name%0ALevel: $level%0ARecently seen playing:%0A1. $game1%0A2. $game2%0A3. $game3" 61 | } 62 | libtelegram::sendPhoto $chat_id "https:$userpic" "$response" "html" false $msgid "" 63 | putchan $channel "Player: $name https:[strip_html $userpic]" 64 | } else { 65 | set response "[::msgcat::mc MSG_PSN_NOTFOUND]" 66 | libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 67 | putchan $channel "[strip_html $response]" 68 | } 69 | return 0 70 | } else { 71 | return -1 72 | } 73 | } 74 | 75 | ::telegram::addPublicTgCommand psn psn_getPSNInfo "[::msgcat::mc MSG_PSN_HELP]" 76 | -------------------------------------------------------------------------------- /modules/Quotes.conf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API Quote module for Eggdrop v20180731 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | set ::Quotes::quote_database [file join [file dirname [info script]] quote.txt] 12 | 13 | # Messages for the Quote-module 14 | ::msgcat::mcset de MSG_QUOTE_NOTEXIST "Zitat nummer %s nicht gefunden." 15 | ::msgcat::mcset de MSG_QUOTE_NOTFOUND "Kein Zitaten mit %s gefunden." 16 | ::msgcat::mcset de MSG_QUOTE_QUOTEADDED "Zitat ist am der Zitatliste hinzugefügt." 17 | ::msgcat::mcset de MSG_QUOTE_HELP "(Stichwort/id): Sehe sich ein Zitat aus der legendären Zitatdatenbank an." 18 | ::msgcat::mcset de MSG_QUOTE_ADDHELP ": Fügt ein Zitat an der legendären Zitatdatenbank hinzu." 19 | 20 | ::msgcat::mcset en MSG_QUOTE_NOTEXIST "Quote number %s does not exist." 21 | ::msgcat::mcset en MSG_QUOTE_NOTFOUND "No quotes with %s found." 22 | ::msgcat::mcset en MSG_QUOTE_QUOTEADDED "Quote has been added to the quote-list." 23 | ::msgcat::mcset en MSG_QUOTE_HELP "(keyword/id): View a quote from the legendary quote database." 24 | ::msgcat::mcset en MSG_QUOTE_ADDHELP ": Adds a quote to the legendary quote database." 25 | 26 | ::msgcat::mcset nl MSG_QUOTE_NOTEXIST "Quote nummer %s bestaat niet." 27 | ::msgcat::mcset nl MSG_QUOTE_NOTFOUND "Geen quotes met %s gevonden." 28 | ::msgcat::mcset nl MSG_QUOTE_QUOTEADDED "Quote is toegevoegd aan de quote-lijst." 29 | ::msgcat::mcset nl MSG_QUOTE_HELP "(zoekterm/id): Laat een quote uit de legendarische quote database te zien." 30 | ::msgcat::mcset nl MSG_QUOTE_ADDHELP ": Voeg een quote toe aan de legendatische quote database." 31 | 32 | -------------------------------------------------------------------------------- /modules/Quotes.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API Quote module for Eggdrop v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | namespace eval Quotes {} 8 | source "[file join [file dirname [info script]] Quotes.conf]" 9 | 10 | # ---------------------------------------------------------------------------- # 11 | # Quote procedures # 12 | # ---------------------------------------------------------------------------- # 13 | # Get a quote from the quote-database # 14 | # ---------------------------------------------------------------------------- # 15 | 16 | proc quotes_getQuote {from_id chat_id msgid channel message parameter_start} { 17 | global quote_database 18 | 19 | set quote_id [string trim [string range $message $parameter_start end]] 20 | 21 | set quote_fd [open "$::Quotes::quote_database" r] 22 | for {set quote_count 0} { ![eof $quote_fd] } {incr quote_count} { 23 | gets $quote_fd quote_list($quote_count) 24 | } 25 | close $quote_fd 26 | 27 | set quote_count [expr $quote_count - 1] 28 | if {$quote_id == ""} { 29 | set quote_id [rand $quote_count] 30 | set qot_sel $quote_list($quote_id) 31 | } else { 32 | if {[string is integer $quote_id]} { 33 | unset quote_list($quote_count) 34 | unset quote_list([expr $quote_count - 1]) 35 | if {![info exists quote_list([expr {$quote_id} - 1])]} { 36 | set qot_sel [::msgcat::mc MSG_QUOTE_NOTEXIST $quote_id] 37 | } else { 38 | set qot_sel $quote_list([expr {$quote_id} - 1]) 39 | } 40 | } else { 41 | set quote_id [string tolower $quote_id] 42 | 43 | set quote_sel_num 0 44 | for {set i 0} {$i < $quote_count} {incr i} { 45 | if {[string first $quote_id [string tolower $quote_list($i)]] != -1} { 46 | set quote_selection($quote_sel_num) $quote_list($i) 47 | incr quote_sel_num 48 | } 49 | } 50 | 51 | if {$quote_sel_num == 0} { 52 | set qot_sel [::msgcat::mc MSG_QUOTE_NOTFOUND $quote_id] 53 | } else { 54 | set qot_sel $quote_selection([set qot_cur [rand $quote_sel_num]]) 55 | } 56 | } 57 | } 58 | 59 | ::libtelegram::sendMessage $chat_id "[url_encode $qot_sel]" "html" false $msgid "" 60 | putchan $channel "[::libunicode::utf82ascii $qot_sel]" 61 | 62 | return 0 63 | } 64 | 65 | # ---------------------------------------------------------------------------- # 66 | # Add a quote to the quote-database # 67 | # ---------------------------------------------------------------------------- # 68 | 69 | proc quotes_addQuote {from_id chat_id msgid channel message parameter_start} { 70 | global quote_database 71 | 72 | set quote [string trim [string range $message $parameter_start end]] 73 | 74 | if {$quote ne ""} { 75 | file copy -force "$::Quotes::quote_database" "$::Quotes::quote_database~" 76 | set quote_fd [open "$::Quotes::quote_database" a+] 77 | puts $quote_fd "$quote" 78 | close $quote_fd 79 | 80 | ::libtelegram::sendMessage $chat_id "[::msgcat::mc MSG_QUOTE_QUOTEADDED]" "html" false $msgid "" 81 | putchan $channel "[::msgcat::mc MSG_QUOTE_QUOTEADDED]" 82 | 83 | return 0 84 | } else { 85 | return -1 86 | } 87 | } 88 | 89 | ::telegram::addPublicTgCommand quote quotes_getQuote "[::msgcat::mc MSG_QUOTE_HELP]" 90 | ::telegram::addPublicTgCommand addquote quotes_addQuote "[::msgcat::mc MSG_QUOTE_ADDHELP]" 91 | -------------------------------------------------------------------------------- /modules/Soundcloud.conf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API SoundCloud module for Eggdrop v20180212 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | # Messages for the Soundcloud-module 12 | ::msgcat::mcset de MSG_SOUNDCLOUD_HELP ": Suche SoundCloud nach Musik, die zu passt." 13 | ::msgcat::mcset de MSG_SOUNDCLOUD_NOTFOUND "Nichts gefunden." 14 | ::msgcat::mcset de MSG_SOUNDCLOUD_NOVALID "Keine gültige Antwort von Soundcloud-Servern erhalten (der Server ist möglicherweise inaktiv)." 15 | 16 | ::msgcat::mcset en MSG_SOUNDCLOUD_HELP ": Search SoundCloud for music matching ." 17 | ::msgcat::mcset en MSG_SOUNDCLOUD_NOTFOUND "Nothing found." 18 | ::msgcat::mcset en MSG_SOUNDCLOUD_NOVALID "Got no valid response from Soundcloud servers (server may be down)." 19 | 20 | ::msgcat::mcset nl MSG_SOUNDCLOUD_HELP ": Zoek muziek op SoundCloud naar ." 21 | ::msgcat::mcset nl MSG_SOUNDCLOUD_NOTFOUND "Niets gevonden." 22 | ::msgcat::mcset nl MSG_SOUNDCLOUD_NOVALID "Geen geldig antwoord gekregen van de Soundcloud servers (server kan onbereikbaar zijn)." 23 | -------------------------------------------------------------------------------- /modules/Soundcloud.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Soundcloud module for Eggdrop with the Telegram-API module v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | source "[file join [file dirname [info script]] Soundcloud.conf]" 12 | 13 | # ---------------------------------------------------------------------------- # 14 | # Soundcloud procedures # 15 | # ---------------------------------------------------------------------------- # 16 | # Search a track on Soundcloud # 17 | # ---------------------------------------------------------------------------- # 18 | 19 | proc soundcloud_getTrack {from_id chat_id msgid channel message parameter_start} { 20 | if {[set query [string map {" " "%20"} [string trim [string range $message $parameter_start end]]]] ne ""} { 21 | if { [ catch { 22 | set result [exec curl --tlsv1.2 -s -X GET https://api.soundcloud.com/tracks.json?client_id=4346c8125f4f5c40ad666bacd8e96498&q=$query&limit=1] 23 | } ] } { 24 | putlog "Soundcloud.tcl: cannot connect to api.soundcloud.com using tracks.json method." 25 | return -1 26 | } 27 | 28 | if {[::libjson::getValue $result "total"] eq "0"} { 29 | set response "[::msgcat::mc MSG_SOUNDCLOUD_NOTFOUND]" 30 | } else { 31 | if {[set response [::libjson::getValue $result "permalink_url"]] eq -1} { 32 | set response "[::msgcat::mc MSG_SOUNDCLOUD_NOVALID]" 33 | } 34 | } 35 | 36 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 37 | putchan $channel "[strip_html $response]" 38 | 39 | return 0 40 | } else { 41 | return -1 42 | } 43 | } 44 | 45 | ::telegram::addPublicTgCommand soundcloud soundcloud_getTrack "[::msgcat::mc MSG_SOUNDCLOUD_HELP]" 46 | -------------------------------------------------------------------------------- /modules/Spotify.conf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Telegram-API Spotify module for Eggdrop v20180212 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | # Messages for the Spotify-module 12 | ::msgcat::mcset de MSG_SOUNDCLOUD_HELP ": Suche Spotify nach Musik, die zu passt." 13 | ::msgcat::mcset de MSG_SOUNDCLOUD_NOTFOUND "Nichts gefunden." 14 | 15 | ::msgcat::mcset en MSG_SPOTIFY_HELP ": Search Spotify for music matching ." 16 | ::msgcat::mcset en MSG_SPOTIFY_NOTFOUND "Nothing found." 17 | 18 | ::msgcat::mcset nl MSG_SPOTIFY_HELP ": Zoek muziek op Spotify naar ." 19 | ::msgcat::mcset nl MSG_SPOTIFY_NOTFOUND "Niets gevonden." 20 | -------------------------------------------------------------------------------- /modules/Spotify.tcl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- # 2 | # Spotify module for Eggdrop with the Telegram-API module v20181119 # 3 | # # 4 | # written by Eelco Huininga 2016-2018 # 5 | # ---------------------------------------------------------------------------- # 6 | 7 | # ---------------------------------------------------------------------------- # 8 | # Configuration settings # 9 | # ---------------------------------------------------------------------------- # 10 | 11 | source "[file join [file dirname [info script]] Spotify.conf]" 12 | 13 | # ---------------------------------------------------------------------------- # 14 | # Spotify procedures # 15 | # ---------------------------------------------------------------------------- # 16 | # Search a track on Spotify # 17 | # ---------------------------------------------------------------------------- # 18 | 19 | proc spotify_getTrack {from_id chat_id msgid channel message parameter_start} { 20 | if {[set spotifyquery [string map {" " "%20"} [string trim [string range $message $parameter_start end]]]] ne ""} { 21 | if { [ catch { 22 | set result [exec curl --tlsv1.2 -s -X GET https://api.spotify.com/v1/search?q=$spotifyquery&type=track&limit=1] 23 | } ] } { 24 | putlog "Spotify.tcl: cannot connect to api.spotify.com using search method." 25 | return -1 26 | } 27 | 28 | if {[::libjson::hasKey $result ".error"]} { 29 | set response "Error [::libjson::getValue $result ".error.status"] [::libjson::getValue $result ".error.message"]" 30 | } else { 31 | if {[::libjson::getValue $result "total"] eq "0"} { 32 | set response "[::msgcat::mc MSG_SPOTIFY_NOTFOUND]" 33 | } else { 34 | set response [::libjson::getValue $result "spotify"] 35 | } 36 | } 37 | 38 | ::libtelegram::sendMessage $chat_id "$response" "html" false $msgid "" 39 | putchan $channel "[strip_html $response]" 40 | 41 | return 0 42 | } else { 43 | return -1 44 | } 45 | } 46 | 47 | ::telegram::addPublicTgCommand spotify spotify_getTrack "[::msgcat::mc MSG_SPOTIFY_HELP]" 48 | -------------------------------------------------------------------------------- /web/tg.php: -------------------------------------------------------------------------------- 1 | $file_id_max_length)) { 22 | header ('HTTP/1.0 400 Bad Request'); 23 | header ('Content-Type: text/plain'); 24 | writeLogfile(" - FAILED file_id length ( bytes)\n"); 25 | die ('0x00000001'); 26 | } 27 | if (!ctype_print($file_id)) { 28 | header ('HTTP/1.0 400 Bad Request'); 29 | header ('Content-Type: text/plain'); 30 | writeLogfile(' - FAILED file_id ctype_print\n'); 31 | die ('0x00000002'); 32 | } 33 | if (preg_match("/[^A-Za-z0-9\-_]/", $file_id)) { 34 | header ('HTTP/1.0 400 Bad Request'); 35 | header ('Content-Type: text/plain'); 36 | writeLogfile(' - FAILED file_id preg_match\n'); 37 | die ('0x00000003'); 38 | } 39 | 40 | # Get the link to the attachment 41 | try { 42 | $content = file_get_contents('https://api.telegram.org/bot' . $bot_id . ':' . $bot_token . '/getFile?file_id=' . $file_id, false, NULL, 0, $max_file_size); 43 | 44 | if ($content === false) { 45 | header ('HTTP/1.0 504 Gateway Time-out'); 46 | header ('Content-Type: text/plain'); 47 | writeLogfile(' - FAILED at getLink1\n'); 48 | die ('0x0000001A'); 49 | } 50 | } catch (Exception $e) { 51 | header ('HTTP/1.0 400 Bad Request'); 52 | header ('Content-Type: text/plain'); 53 | // var_dump ($e); 54 | writeLogfile(' - FAILED at getLink2 ' . $e->getMessage() . '\n'); 55 | die ('0x0000001B'); 56 | } 57 | 58 | # Translate the JSON response from the Telegram server 59 | $json = json_decode(utf8_encode($content), true); 60 | 61 | # Do some sanity checking 62 | if ($json['result']['file_size'] > $max_file_size) { 63 | header ('HTTP/1.0 400 Bad Request'); 64 | header ('Content-Type: text/plain'); 65 | writeLogfile(' - FAILED file too big (' . $json['result']['file_size'] . ' bytes)\n'); 66 | die ('0x0000001C'); 67 | } 68 | 69 | # Get the attachment itself from the Telegram server 70 | try { 71 | $content = file_get_contents('https://api.telegram.org/file/bot' . $bot_id . ':' . $bot_token . '/' . $json['result']['file_path'], false, NULL, 0, $max_file_size); 72 | 73 | if ($content === false) { 74 | header ('HTTP/1.0 504 Gateway Time-out'); 75 | header ('Content-Type: text/plain'); 76 | writeLogfile(' - FAILED at getAttachment1\n'); 77 | die ('0x0000002A'); 78 | } 79 | } catch (Exception $e) { 80 | header ('HTTP/1.0 400 Bad Request'); 81 | header ('Content-Type: text/plain'); 82 | // var_dump ($e); 83 | writeLogfile(' - FAILED at getAttachment2 ' . $e->getMessage() . '\n'); 84 | die ('0x0000002B'); 85 | } finally { 86 | # Prep the appropiate headers 87 | header('Cache-Control: no-cache, must-revalidate'); 88 | header('Expires: Wed, 21 Oct 2015 07:28:00 GMT'); 89 | header('Content-Length: ' . basename($json['result']['file_size'])); 90 | header('Content-Type: application/octet-stream'); 91 | header('Content-Disposition: attachment; filename="' . basename($json['result']['file_path']) . '"'); 92 | 93 | # Make sure the output buffer is empty, and send the attachment 94 | ob_clean(); 95 | flush(); 96 | print $content; 97 | writeLogfile('\n'); 98 | exit; 99 | } 100 | 101 | function writeLogfile($text) { 102 | global $logfile, $logfileEnabled; 103 | 104 | if ($logfileEnabled) { 105 | file_put_contents($logfile, $text, FILE_APPEND | LOCK_EX); 106 | } 107 | } 108 | ?> 109 | --------------------------------------------------------------------------------