FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!

Making a Telegram bot with Node.js




When I started learning Javascript the last thing I thought I would be doing was a Telegram bot. I wanted to do one, but it's usually a client-side language, filled with browser-specific names and methods. Like for example:

Code:

<p>A paragraph</p>
<p id="myId">A paragraph with an ID to make it selectable</p>
<script>
document.getElementById("myId").onclick = function() {aFunction()};
function myFunction() {
    document.getElementById("myId").innerHTML = "Paragraph text changed.";
};
</script>


I really like Javascript and its event-based behaviour, but I had never thought that with all those "getElementById" and "document" and "innerHTML" that were all browser-specific, I would ever be able to do anything else. It was a surprise to me when a friend gave me a Telegram bot and told me it was written in Javascript. At first I didn't think about it, let the days pass, and then I came back to it while I was learning Javascript and thought "wow, how can this be written in Javascript?". I asked around and got to Node.js. That was three weeks ago and I haven't let a day pass without doing something different on Node.js. The event-based code, used for server-side language with node, really allows for some quirky little tricks that are just lovely. Together with all the modules that translate whatever happens anywhere on the internet to readable events, it's just a magnificent tool for creating a bot.



0 blog comments below




FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.