/Dentaku

Primary LanguagePython

Dentaku

Dentaku is VikingsDev's open source messenger bot.

Setting up a development environment

  1. Clone repository git clone https://github.com/VikingsDev/Dentaku.git
  2. Create virtual environment python -m venv venv
  3. Create export file touch export.sh
  4. Edit export.sh using a text editor, and add
export EMAIL=YOUR_FACEBOOK_ACCOUNT_EMAIL
export PASSWORD=YOUR_FACEBOOK_ACCOUNT_PASSWORD
  1. Run the bot python main.py

Contribution guidelines

To add your own command, create a file named your command. For example, if I wanted to make a command called dog, and I wanted users to run it as !dog, I would create a file called dog.py

Inside dog.py, start with this template:
(replace all occurences of dog with your command name)

from command import Command
from fbchat import Message
from fbchat import Mention


class dog(Command):

    def run(self):
        response_text = "@" + self.author.first_name + " Hello world! This is a dog command."
        mentions = [Mention(self.author_id, length=len(self.author.first_name) + 1)]

        self.client.send(
            Message(text=response_text, mentions= mentions),
            thread_id=self.thread_id,
            thread_type=self.thread_type
        )

These links might be helpful:

fbchat Examples
fbchat Full Documentation

command.py, The Command Class

All commands must inherit command.py
Inheriting command.py gives you these variables:

self.user_params

Parameters that the user passed in along with the command.

Example: "!dog p1 p2 p3"
user_params = ["p1","p2","p3"]

self.author_id

ID of the person who sent this command.br>

self.message_object

The command's message object

Type: fbchat.Message

self.thread_id

ID of the chat this command was sent in

self.thread_type

Type of the chat this command was sent in

Type: fbchat.ThreadType(enum)

self.client

The Dentaku user account

Type: fbchat.Client

self.author

The object of the person who sent this message.

Type: fbchat.User