usdevs / cinnabot

MIT License
2 stars 5 forks source link
hacktoberfest

Cinnabot :robot:

Build Status Telegram

Telegram Bot for Cinnamon College. Telegram

Features:

Got a feature to suggest? :bulb: Bug to report? :bug: You are welcome to file an issue here.

Documentation quick links

Setting up the environment :earth_asia:

0. Install essential packages

We will first need to install git and golang. First install git using your favourite package manager:

Ubuntu/Debian derivatives using APT

sudo apt install git

MacOS using Homebrew :beer:

brew install git

Then, install Golang version 1.15. You can either download it from the official website or download it using a package manager (remember to check the go version provided by the package manager).

For Linux systems, you can follow the steps if you downloaded go from the website:

cd Downloads # or wherever you downloaded the file
sudo tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz
# change the lines below to the shell you are using
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
source ~/.bashrc

To verify that Golang is installed properly:

$ which go # only for Mac/Linux
/usr/local/go/bin/go # it's okay for this to differ, it just shouldn't be blank
$ go version
go version go1.15.2 linux/amd64 # version, operating system/architecture

1. Clone the cinnabot repository

Go the the directory where you want to store the cinnabot code, and run this command to download the cinnabot repository into a new directory called 'cinnabot':

git clone https://github.com/usdevs/cinnabot.git 
# or git@github.com:usdevs/cinnabot.git if you are using a ssh key

Voila! Now we have cinnabot on our machine. Ready to go!! :tada:

Testing Cinnabot locally

Overview:

  1. Register for an API Token with BotFather
  2. Running a test bot on Telegram

All instructions below assume you are at the cinnabot root path, unless stated otherwise.

1. Register for an API Token with Botfather

Ask for the blessings of the Botfather here, as you register for one of the bots. You will be provided, with honor, an API token where you should put into main/config.json.

In other words, click on the link and choose a Telegram handle for your bot, which ends with ...bot and is not taken yet. Once you are done, you will be provided with the API Token.

Then, we create our config.json file using the example file config.json.example, and replacing the dummy API Token with the one we just registered.

cd main
cp config.json.example config.json

Fire up your favourite text editor and replace the dummy string in config.json with your API Token as a string.

2. Running a test bot on Telegram

cd main
go run main.go

And start testing! Fire up your favourite Telegram client, and find the bot by the name you registered it with. You can now test all cinnabot functionalities on your testbot.

When you are done, press Ctrl+C on your terminal to end testing.