Dentaku
Dentaku is VikingsDev's open source messenger bot.
Setting up a development environment
- Clone repository
git clone https://github.com/VikingsDev/Dentaku.git
- Create virtual environment
python -m venv venv
- Create export file
touch export.sh
- Edit
export.sh
using a text editor, and add
export EMAIL=YOUR_FACEBOOK_ACCOUNT_EMAIL
export PASSWORD=YOUR_FACEBOOK_ACCOUNT_PASSWORD
- 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
Class
command.py, The All commands must inherit command.py
Inheriting command.py
gives you these variables:
Parameters that the user passed in along with the command.
Example: "!dog p1 p2 p3"
user_params = ["p1","p2","p3"]
ID of the person who sent this command.br>
The command's message object
Type: fbchat.Message
ID of the chat this command was sent in
Type of the chat this command was sent in
Type: fbchat.ThreadType(enum)
The Dentaku user account
Type: fbchat.Client
The object of the person who sent this message.
Type: fbchat.User