Saturday, May 30, 2015

Early Preview: telegram-pybot - A Telegram Bot based on Plugins, written in Python

We have all used and loved Yago's telegram-bot written in Lua as an extension for Vitaly Valtman's tg-cli for making funny Telegram bots. But Lua was keeping a lot of people away from making meaningful plugins.

Alternate approaches included adding a --json flag to vysheng's tg-cli and parsing that data or building wholly native APIs for Telegram in java or other languages. Liberbot is an excellent example.

Now, the developers at Datamachine Studios have come up with a Python interface for building bots. I have tested it and it works very well, even at this very early stage.

Screenshot of the bot listing its plugins on command
What?
Spartanly named "telegram-pybot" (for now, hopefully), what these people have created is a wrapper around vysheng's tg-cli. They did this by patching the cli with Python interfaces and contributing to the upstream (that's the beauty of free software).

Why not native Python API?
Apparently, the developers of telegram-pybot started out making plugins for the Lua bot. Later when they realized they wanted to switch to Python, it was easier to mimic the Lua binding API in Python rather than deal with the whole logic of Telegram (which keeps updating the schemas every now and then too). And many people are trying their hand in developing a pure Python API, should any of them become stable telegram-pybot is in a good space to switch to such a native interface with very little work in the future.

"It's kind of a pipe dream of mine to work on a python API, but one thing at a time right now" says Phillip Lopo who's one of the two main forces behind the bot.

Python vs Lua
In my experience, Lua can only be at best called a scripting language, albeit a powerful one, while Python is a power packed, complete programming language. The sheer number of libraries available in Python and the pythonic way of doing things makes development in Python much more easy compared to Lua. Also, threading is a huge weakness in Lua which has mostly been solved in telegram-pybot already.

Plugins
The sweetest feature of telegram-pybot is its plugin management system. It is promising even while currently undergoing heavy development. Plugins are organized by repositories. One can search, list, install, update, etc the plugins available in a repository. Soon multiple repositories will be supported so that anyone can maintain their own list of plugins in a repository and others can easily get hold of more plugins, thus also avoiding a single point of failure.

And the plugins themselves run quite smoothly, and cause no trouble even when they crash. Installing new plugins, restarting the bot, etc can be done over a Telegram chat thereby making them super easy to use (even for a non-developer)

License
Licensing bots, especially when they are powered by plugins is a confusing affair (read about the licensing of Yago's bot). GPL offers no protection to bots that run over the network and therefore if one has to choose a copyleft license, it must be AGPL.

But the developers of telegram-pybot want to give away as much freedom as possible. "I want people to use it, and I want the option for people to write private plugins for private communities" says Vincent Castellano, the co-developer. So there's a good chance they will settle for MIT or BSD license when they finish their primary work on the code.


With all that said, the bot is still in active development, as their readme says:
"While already very capable, this bot is still in relatively early development. Some plugin names, or plugin API calls may be modifed. However, we are starting to settle on our stable APIs."

But you should check it out already -- github.com/datamachine/telegram-pybot


When I discovered telegram-pybot last night, I was very excited. And I developed a plugin which we're enjoying in our FSM-K Telegram group. It is so easy to build that I want anyone with a computer to try, and therefore I've written a tutorial on my website.


If you like what you're reading, subscribe!

Get posts via email:

Thursday, May 28, 2015

[jog-journal] The Idea

They say an idle mind is devil's workshop. A jogger's mind is god's workshop then.

I'm waking up at 4 am since I had a sweet dream yesterday.

Some goons appear outside a hostel. They beat the two securitiy guys up and ask them to go inside, take the mobile phone from every guy sleeping inside, and hand it over to them. The clever securities went inside and woke all the guys up. The guys started coming out one by one and soon the goons fled seeing the crowd.
When I woke up I had the realization that individually we are all powerless, but if we can wake people up to the reality, we can fend off any enemy.

That was yesterday. Today I had no dream to wake up with. This thread is going on about licensing of a Telegram based bot. If the license is AGPL, does it protect the bot as we want it to be protected? I've sent an email to FSF because the answer isn't clear from their FAQ either. Then I started making a teaching kit called "Internet elevator pitch for administrators" after wondering how I'd make my college Dean understand the importance of URLs. (My college's official website is mmcrimysore.org.in. If you're to visit it, you'll be redirected to the subdomain of the website of the web developer (I'm ashamed to call that guy by this title). And the guy says the official URL will be used once the website is completed. Poor administration should have believed that.)

It was 6 o'clock by then and fairly sunlit. And I was having a bit extra energy and so I went jogging to Kukralli kere. There are bulldozers around the entrance laying down huge pipes and I had to jog anti-clockwise today because the other entrance was blocked with soil. I remember reading somewhere that running anti-clockwise is good for the heart, but I wonder if that's true for large circles (or even small circles). Also, what happens to the previous tar on the road when it is being retarred?

Halfway through I noticed a woman running with a stooping posture. She didn't look tired and she was young enough to be not having senile stoop. Do women assume certain positions while jogging to avoid uncomfortable jiggling of their breasts? Can this be avoided by wearing appropriate sports bra? If yes, maybe a bra-salesman can make a fortune at the entrance of Kukralli kere. After all there is already a leafy vegetables/hurbs guy, a glucometer guy, and even water purifier guys there.

I was in the home stretch by then and I saw an Eagle being carried away by wind. Wind flows from water to land in the day, doesn't it? That's why there was wind I guess. And then a blue bird about the size of a small crane with 4 long fingers.

I should write all this down on my blog! After switching to my website for all serious stuff I have been wondering what I'd do with this blog. Maybe this is the right place to write all these random thoughts. Maybe I should name it "Jog Journals". Oh! That'd be fantastic. It'd keep me jogging every day because I've to write the journal and it'd keep me writing every day in turn.

Just as I was fancying that idea something happened. I had been jogging regularly in first year. We had a group who'd go jogging and we'd complete the Kukralli round in 20 minutes and be back. But we lost that habit during university examinations. After that the only real reason that made me go jogging was this girl, in my immediate junior batch, who likes running a lot and whom I like a lot because of that. I knew she came to Kukralli every morning but I'd never ran into her despite adjusting my timing frequently. Incidentally right at the end of the round I saw her and she said "hey" and I said "hi". Ha!

I have absolutely no doubt that there will be enough interesting things/thoughts every day to fill this series with. Yes, a series, that's the idea. Keep looking for the tag jog-journal.


If you like what you're reading, subscribe!

Get posts via email:

Monday, May 11, 2015

Mozilla India Task Force Meetup - 2015

Either of Shreyas or Jafar must have invited me to the Task Force meetup, and I got to be a part of the Mozilla India Task Forces.

The 2015's task forces were formed in an event at Bangalore (Lemon Tree hotel, Ulsoor lake) over 7, 8, 9, 10 May, 2015.

On 7th and 8th, it was previous task force members discussing, evaluating, etc and planning.

I reached the venue on 8th night.

Day 1

In the morning, George Roter talked about the mission of Mozilla and the goals for 2015.

Afterwards, there was an activity to recall what Input -> Activities -> Output -> Outcome -> Impact was.

After lunch, the task force concept was introduced. And all the task forces were introduced, including the newly proposed ones.

Then we divided into groups based on the task force we were interested in joining.

I joined policy and advocacy task force which was a newly formed Task Force to cover policy issues and also raise awareness about those, privacy, security, etc. We discussed our skills, our roles, our interests and what help we need. Later we aligned these to the Mozilla's 2015 goals. More about the Task Force in the wiki.

In the night, I downloaded the mozilla-central code from the mercurial repository and built my own firefox (ASDfox)

Day 2

Day 2 was really intensive. We wrote down our short term goals and long term goals for each task force.

George did a workshop on Fennec, we made personas, discovered a lot of ideas and challenges.

Towards the end, we finalized the strucutre of the task force and presented the important goals to the group.

[These notes are super short because there is too much going on and I don't even have time to note them down before forgetting, let alone expand.]


If you like what you're reading, subscribe!

Get posts via email:




One more time, subscribe via email: