<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Antonio Pitasi</title>
    <description>The latest articles on DEV Community by Antonio Pitasi (@zaphodias).</description>
    <link>https://dev.to/zaphodias</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F37610%2F77d9e857-b88a-4ec7-abde-8c08e4238281.jpeg</url>
      <title>DEV Community: Antonio Pitasi</title>
      <link>https://dev.to/zaphodias</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zaphodias"/>
    <language>en</language>
    <item>
      <title>Advice needed: writing a paper/thesis</title>
      <dc:creator>Antonio Pitasi</dc:creator>
      <pubDate>Sat, 11 Aug 2018 19:06:31 +0000</pubDate>
      <link>https://dev.to/zaphodias/advice-needed-writing-a-paperthesis-3f33</link>
      <guid>https://dev.to/zaphodias/advice-needed-writing-a-paperthesis-3f33</guid>
      <description>&lt;p&gt;My little background: I just started writing (in english, definitely not my native language) my CS undergraduate degree thesis after a 3 months internship in a startup that helped me realizing a blockchain based application for the IOT.&lt;/p&gt;

&lt;p&gt;Of course I have contact with my professor, but I wanted to ask here if anyone have some experience and wants to share some tips :)&lt;/p&gt;

&lt;p&gt;I started reading a couple of other thesis shared from the professor, I understand they are not blog posts and must be formal - but is it okay if they are boring? Also, should I go deep into details (even the ones that seems obvious) and explain literally &lt;em&gt;everything&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Thank you :)&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>beginners</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Simple Telegram's bot with Node.js</title>
      <dc:creator>Antonio Pitasi</dc:creator>
      <pubDate>Mon, 06 Nov 2017 10:34:46 +0000</pubDate>
      <link>https://dev.to/zaphodias/simple-telegrams-bot-with-nodejs-317</link>
      <guid>https://dev.to/zaphodias/simple-telegrams-bot-with-nodejs-317</guid>
      <description>&lt;p&gt;First article here, yeah!&lt;/p&gt;

&lt;p&gt;Today we are going to build an awesome Telegram's bot.&lt;br&gt;
You will need a little Node.js and &lt;a href="https://core.telegram.org/bots/api" rel="noopener noreferrer"&gt;Telegram's bot platform&lt;/a&gt; knowledge.&lt;br&gt;
Yup, I won't teach you something you can already read somewhere else.&lt;/p&gt;

&lt;p&gt;We'll use &lt;a href="https://telegraf.js.org/" rel="noopener noreferrer"&gt;Telegraf.js&lt;/a&gt; as a &lt;em&gt;wrapper/framework&lt;/em&gt; for Telegram API. It's a pretty awesome library which simplifies a lot of annoying tasks you will encounter while developing bots.&lt;br&gt;
&lt;strong&gt;Plus, it is &lt;a href="https://en.wikipedia.org/wiki/Message-oriented_middleware" rel="noopener noreferrer"&gt;middleware powered&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enough talk, let's begin. Our bot will have a list of keywords, or commands, which will trigger a reply. The bot reply can be a simple text message, a sticker, or an animated GIF:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9fkk7fjoscmpvux4x7q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9fkk7fjoscmpvux4x7q.gif" alt="A cool Batman GIF" width="500" height="263"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Creating the bot account
&lt;/h2&gt;

&lt;p&gt;Assuming you are already familiar with Telegram, contact the &lt;a href="https://t.me/BotFather" rel="noopener noreferrer"&gt;@BotFather&lt;/a&gt; and create your bot account.&lt;/p&gt;

&lt;p&gt;Please note the token (something like &lt;code&gt;410509983:AAF3kbJrAGKIrW6ceOdrUg-zLlk5Tuy-NhU&lt;/code&gt;), we'll use it later.&lt;/p&gt;

&lt;p&gt;Now you have to &lt;em&gt;disable privacy mode&lt;/em&gt;, in order to make the bot able to read &lt;em&gt;all&lt;/em&gt; the messages in groups and not just commands.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Init the directory
&lt;/h2&gt;

&lt;p&gt;Easy peasy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;coolbot
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;coolbot
&lt;span class="nv"&gt;$ &lt;/span&gt;npm init
&lt;span class="c"&gt;# I'm assuming you already have Node &amp;amp; NPM installed. If not:&lt;/span&gt;
&lt;span class="c"&gt;# https://nodejs.org/en/download/package-manager/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now answer the few questions NPM will ask and - done. We can install Telegraf.js now.&lt;/p&gt;

&lt;p&gt;To do so:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save&lt;/span&gt; telegraf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You will have a package.json file in your folder, edit the &lt;code&gt;scripts&lt;/code&gt; part to add a 'start' script:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node main.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;echo &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Error: no test specified&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &amp;amp;&amp;amp; exit 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  3. Let's code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh4v0pduyhat3myd828j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh4v0pduyhat3myd828j.gif" alt="Coding is fun" width="760" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I think the code it's pretty easy to understand, I added some comments to make it even easier.&lt;/p&gt;

&lt;p&gt;We want the bot to have a list of trigger, and for each trigger a reply the bot will send. The reply can be a text message, a sticker, or a GIF.&lt;/p&gt;

&lt;p&gt;As a pretty feature, we also want that if I reply to John's message using one of the triggers, the bot should send his message replying to the John's message.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(I know, bad English is strong here.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These triggers will be defined in a separate file later. For now, let's have a look at the core of the bot:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;In this file we are using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;bot.command&lt;/code&gt; to define what to do in case of someone writing &lt;code&gt;/list&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bot.on&lt;/code&gt; to manually define what to do in case of a Telegram event  (any text message)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bot.startPolling&lt;/code&gt; to make the bot start asking Telegram for incoming new messages periodically.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Triggers and replies
&lt;/h2&gt;

&lt;p&gt;Okay now you can customize your bot by creating and editing the &lt;code&gt;replies.js&lt;/code&gt; file:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;To get stickers and GIFs IDs, I suggest sending them to &lt;a href="https://t.me/jsondumpbot" rel="noopener noreferrer"&gt;@jsondumpbot&lt;/a&gt; and look for "file_id" (pay attention to &lt;strong&gt;not&lt;/strong&gt; use file_id of the "thumb"!).&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Running the bot
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk2iqhepa9puezotxkje.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk2iqhepa9puezotxkje.gif" alt="RUN!" width="1024" height="1024"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Easiest part ever:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;410509983:AAF3kbJrAGKIrW6ceOdrUg-zLlk5Tuy-NhU npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Obviously, use your token instead of the sample one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The end
&lt;/h2&gt;

&lt;p&gt;This is it for now. I'm not used to make tutorials and that kind of stuff, so I'll appreciate any comment.&lt;/p&gt;

</description>
      <category>telegram</category>
      <category>chatbot</category>
      <category>node</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
