8 ms·
Botlib: C Telegram bot framework
- agbrrw 3y ago[flagged]
- deleted 3y ago[deleted]
- exxos 3y ago[flagged]
- winterqt 3y agoCertainly the first time I've heard this specific troll remark, good to know that their one joke is still alive and well.
- dang 3y ago"Don't feed egregious comments by replying; flag them instead." a.k.a. please don't feed the trolls https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- latchkey 3y ago[flagged]
- swatcoder 3y agoAfter acheiving a certain level of expertise, most people tinker in the languages they're most fluent with (if they want to focus on the project) or the ones they're curious about (if they want to focus on the language). It's a profound understatement to say that antirez has a certain level of expertise, and a certain fluency, in C.
- davidw 3y agoYes, he does. The next person who picks this up and does something with it might not, though. IMO fun stuff like this is often a good excuse to learn something new and different that might be better in some way, like safety.
- freecodyx 3y agoAgree in general, but as you can see this could’ve been done in other languages with less effort. In c you mostly need to reinvent the wheel
- latchkey 3y agoI started writing C over 20 years ago. That doesn't mean that I'd ever pick it for this.
- tcfhgj 3y agoWhy not, it's not like Telegram uses E2EE
- 38 3y ago[flagged]
- andai 3y agowith C, i literally just do import "cJSON.h"
- BenjiWiebe 3y agoC doesn't have import. Perhaps you meant: #include "cJSON.h"
- andai 3y agoAh, my bad. #define import #include import "cJSON.h"
- 38 3y agoeven if that was valid syntax (its not), that is not the same thing at all. #include is just a "dumb" macro, that literally just dumps the file contents in that spot, so have fun figuring out where an identifier came from in the global scope!
- fsckboy 3y ago>have fun figuring out where an identifier came from in the global scope! grep?
- thowaway91234 3y ago[flagged]
- nnx 3y agoBut then it's hard to imagine much better than the existing Telebot library, which is a very elegant and idiomatic Go. https://github.com/tucnak/telebot https://github.com/tucnak/telebot
- thowaway91234 3y agowhoa, had no idea this existed - looks fantastic thanks for sharing
- duskwuff 3y agoAre you aware of any similarly definitive library for the Telegram user (non-bot) API?
- haltist 3y ago[flagged]
- sitzkrieg 3y agoyea, it's certainly impossible and no one is capable of knowing what they're doing. eyeroll
- haltist 3y agoI wouldn't say it's impossible but certainly much harder than Python.
- YiraldyGuber 3y ago>Whatever can be done in C in this case can be done with Python This mindset is why, in a future not far away from now, we will have 20GHz 512-core IoT widgets with 8TB of RAM that still take 4 seconds to turn the lights on.
- haltist 3y agoIsn't that just basic radio engineering? What does C have to do with radios?
- YiraldyGuber 3y agoWait, do you even realise how much slower and more resource-intensive Python is than a compiled language like C?
- haltist 3y agoReally? Oh wow, I did not know that. I thought all languages with recursion and loops were Turing complete. Are you saying there is some kind of difference between C and Python as far as what programs can be written in them or is this something else?
- dang 3y agoAll: can we please talk about something more interesting than how you don't like the language choice? If a project belongs on HN's front page, which I presume this one does, there must be more interesting things to talk about than that.
- davidw 3y agoOn what is a day off in the middle of a long weekend for many in the US, there's something comforting about returning to familiar traditions like eating leftover turkey, spending time with relatives, shopping, and arguing about programming languages.
- bch 3y agoFfs… I thought you were just joking around until I scrolled down into piles of dead threads.
- davidw 3y agoMy guess is it got posted and noticed because "antirez did a thing" rather than a particular interest in Telegram bots. antirez is a bright guy and worth paying attention to, but I think this is just him having some fun. Edit: aha, here's what he's actually using it for. https://twitter.com/antirez/status/1727969700783460734 https://twitter.com/antirez/status/1727969700783460734
- bch 3y agoWell, it’s sort of neat to me. I’ll probably build some bindings too. Know any good scripting languages?
- matheusmoreira 3y agoYou weren't kidding. Now I want to make a little bot too. In freestanding C with direct Linux system calls. :)
- hombre_fatal 3y ago
- jcul 3y agoThe example mybot.c looks very clean and simple, nice project. It's been a while since I played with telegram bots, but I remember thinking it is one of the best APIs I've used. So simple to register a bot directly through the chat interface with the not father, and a 5 second job to add message posting to a bash script etc.
- hyperfuturism 3y agoSeconded on the Telegram bot API. I've used both Discord's bot API as well, and can say it was way more convoluted to get up and going. Telegram's API was a joy to build in. This was in Node.js.
- pawelduda 3y agoIs there a simple API to read my chats programmatically? Not a bot, but on my own TG account? I was confused by this a while ago
- GaggiX 3y agoYou need to use the "Telegram API": https://core.telegram.org/api#telegram-api https://core.telegram.org/api#telegram-api (not the "Bot API") to develop your client. It uses MTProto to communicate with the server, so I suggest you just use a library that supports it like Telethon if you want to program in Python.
- nazcan 3y agoCare to provide a concrete example of a difference? Curious.
- lawik 3y agoThat they offer long polling as one option for fetching updates makes it incredibly friendly for local development and one-offs. I have had so much fun integrating with Telegram from Elixir. There is a lib (not in hex unfortunately) that makes it all quite straightforward. I even gave a remote talk about it with an interactive demo: https://youtu.be/DFGHaER6_j4?si=sooEsiyVTmfXPqNs https://youtu.be/DFGHaER6_j4?si=sooEsiyVTmfXPqNs Telegram is a mile simpler to get going with than the others.
- synergy20 3y ago[flagged]
- golergka 3y ago[flagged]
- jptv 3y ago[flagged]
- swingingFlyFish 3y ago[flagged]
- nickwanninger 3y ago?
- chaychoong 3y agoDo elaborate! I thought antirez is a pretty well respected programmer.
- haolez 3y agoAntirez sucks! You could easily do this with Redis as a data store ;)
- your_challenger 3y agoHow oblivious does one have to be to call antirez "people who can't code"
- 59nadir 3y ago> user: swingingFlyFish > created: 63 days ago HackerNews is flooded with clueless newcomers, it's not surprising that most of them don't know anything because they're also new to programming, the business and everything else, but usually try to join in on the conversation as if they weren't, because they have a set of opinions that they got from lifestyle YouTubers anyway.
- kiitos 3y ago[flagged]
- antirez 3y agoAuthor here, thank you for having this project on the front page! I want to explain why this bot is in C, while, for instance, another project of mine that implements a LoRa driver/protocol for the ESP32 (a much lower level project, in theory) is in Python! This code started as the Telegram bot Stonky, it's on Github, and you'll see the bot does a lot of financial analysis things, including Montecarlo simulations. I really needed the speed. Later my daughter was diagnosed with scoliosis, and requires to wear a corset. To take track of the time she wears it was a pita, so I wrote another bot (not released so far) and put it in our family channel. Then... I needed another bot. And I finally extracted the common parts from the two. So: 1. For Stonky, speed was essential, but not for my next bot. 2. Once I needed to write the new bot for the corset I tried the Python lib. And... I started to have the first code compatibility issues (accross versions) of the modern software stack (context here: https://twitter.com/antirez/status/1726305869032570992 https://twitter.com/antirez/status/1726305869032570992). 3. Meanwhile Stocky was no longer able to work because I did the unescapable error of basing it on the Yahoo Finance API, now retired :( So I told myself, I don't want to relay on a software stack that will make this bot unable to work or obsolete in 2/3 years because all the libraries will change fast (and, if you check, you will see there was a lot of work that went into Stonky back in the couple of weeks when I worked at it constantly). On top of that, with Stonky I decided to serve each request with a thread, and not in multiplexing. In the specific case of a Telegram bot this is basically able to simplify many things: many bot requests are long living, because you want to call an LLM API, or Whisper to transcribe, or do a Montecarlo simulation on a stock history, (btw the Whisper thing will be one of the official examples of this library) and so forth. Now in Stonky this approach worked so well because it's written in C, so each thread consumes only minimaul resources associated with the OS thread creation. Finally: With SDS lib, my JSON and Sqlite3 wrapper (the wrappers are the interesting part of the project IMHO) it is not so different than writing Python code. So, I said, why not? P.S. this library is just a work in progress, hacked while I'm doing many other stuff. I hope it will improve in the next weeks. I use Telegram for more than 10 years now, with all my friends and family. So it is very likely I'll require to write more bots in the future :D
- jay-barronville 3y agoUnrelated: I just want to say thank you for all of your amazing work over the years. You’re a software hero of mine. I’m 100% certain your code and work has saved me time, money, and maybe even my job at one point! Also, sorry to hear about your daughter. I’m going to pray for you and your family! (If my memory serves me right, you don’t believe in God, but I hope you don’t mind.)
- seanvelasco 3y agowas just looking at the official telegram bot api just last night! i'm going to give this a try, as a way to get more comfortable with C. on a separate note, does anyone know of a stable telegram api (not bot api) in javascript that doesn't require polyfills?
- maxlin 3y agoFYI using non-bot APIs like WTelegram for gathering messages and sending them (even while sending thru a bot account!) gets you rid of the 50MB and similar limits. Source: Run a bot that aggregates and translates several Russian channels for transparency reasons. ~100k msgs processed until now, including hour-long documentaries
- CodeNest 3y ago[flagged]
- theshrike79 3y agoFirst party bot support is one of the biggest reasons I stick with Telegram and Discord for communication. Signal and WhatsApp (to a degree) have E2EE, but zero support for any kinds of bots, making them mostly useless for what I need chat applications for.
- account-5 3y agoI'd be really interested if you could expand on what the point of these bots is? I genuinely don't see the point, why would I need a bit in a normal chat? If I was managing a large chat group on a topic I could possibly see having a bit welcome new sign ups as beneficial ... Either way I don't get the point so want to learn.
- theshrike79 3y agoDiscord bots are their own ecosystem, you can find bots for pretty much anything you can imagine https://discord.bots.gg https://discord.bots.gg For example Midjourney is just a Discord bot you can invite to your own server and use it there. I also ported an old IRC bot that had some specific functionality for a group to a basic Discord bot pretty much in one evening. As for Telegram, I've get most of my server and software notifications via a single Telegram bot. A simple command just calls the API and sends the message to the bot I also have an Octoprint bot on Telegram that I can use to monitor and control my 3D printer remotely. Additionally we have a family channel in Telegram, and a home automation bot sits there. When someone forgets to close a door (front, fridge, freezer) the bot will complain in there. Same with temperature/humidity warnings and notifications. I'll add actual two-way controls when I get around to it, so that we could control the for example AC via the bot.
- CyberDildonics 3y agoI'm surprised no one has questioned why a bot made for one specific program and protocol has a generic name like 'botlib'.
- 0xfedbee 3y agoTo everyone that got flagged before I could read their comments: I will keep writing code in C until I die, and I have just started.
- up2isomorphism 3y agocan language evangelism strike forces just please go away?