Dentaku is VikingsDev's open source messenger bot.
git clone https://github.com/YOUR_GITHUB_USERNAME/Dentaku.git
YOUR_GITHUB_USERNAME
.) python -m venv venv
pip install virtualenv
.)touch export.sh
Notepad export.sh
and accept the prompt to create the new file (or create the file manually in File Explorer) export.sh
using a text editor, and add:
export EMAIL="YOUR_FACEBOOK_ACCOUNT_EMAIL"
export PASSWORD="YOUR_FACEBOOK_ACCOUNT_PASSWORD"
export BITLY_GAT="YOUR_BITLY_GENERIC_ACCESS_TOKEN"
export G_CREDENTIALS="PATH_TO_YOUR_SERVICE_ACCOUNT_JSON"
Note: Replace the strings with your own information, but keep the quotation marks!
Get your bit.ly Generic Access Token, which is required if you want to use commands with link shorteners.
Get your service account credentials, which is required if you want to use commands with Google Cloud integration. This project uses Firebase.
(Remember to hit save in the text editor before activating the variables!)
source venv/bin/activate
venv\Scripts\activate.bat
pip install -r requirements.txt
python main.py
Logging in knarf8700@gmail.com...
Login of knarf8700@gmail.com successful.
Testing mode will restrict all bot interactions to direct messages, or ThreadType.USER.
Turn on testing mode? (y/n):
Follow the dialog, and at the end, you should see Listening...
which confirms that your bot is on and listening to Messenger.
Keep Dentaku running and check your Messenger! You should have received a message from yourself, saying "Dentaku is online." Test the 'help' command by sending
!help
to the chat.
Now you can make your own commands by following the guidelines below. :)
For a full, comprehensive read on contribution, take a look at our CONTRIBUTING.md.
To add your own command, create a file named your command inside the commands
folder. 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 commands
.
Inside dog.py
, start with this template:
(Replace all occurrences 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
)
def define_documentation(self):
self.documentation = {
"parameters": "None",
"function": "Undefined."
}
For more information on defining parameters and functions, look for the self.documentation
variable on Dentaku's Wiki.
These links might be helpful:
fbchat Examples
fbchat Full Documentation