๐Ÿฏ honeybot py [docs ]

September 24, 2024 ยท View on GitHub

PyPI version First Timers Only Open Source Love Made in Moris CII Best Practices OpenSSF Scorecard


๐Ÿ‡ฒ๐Ÿ‡บ ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡จ๐Ÿ‡ฆ ๐Ÿ‡ฆ๐Ÿ‡ท ๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ฌ๐Ÿ‡ฌ ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ธ๐Ÿ‡ฝ ๐Ÿ‡ต๐Ÿ‡ฑ ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฒ๐Ÿ‡ผ ๐Ÿ‡ฒ๐Ÿ‡ฆ

Open Source Helpers Discord

Table of Contents

๐Ÿ“ฎ About

HoneyBot is a python-based IRC bot. (python3.7) | If you want to just run the bot, go to the quick start section

HoneyBot is my first time collaborating to an open source project and I'm loving it. Before discovering HoneyBot, I was very intimidated on the idea of working with other people and had no idea what an IRC even was. Now I realize how much fun and rewarding it is to work together on a project with dedicated and friendly individuals. The documentation is easy to follow and everyone is super helpful. I highly recommend any new programmer who want to contribute on an open source project to try out HoneyBot. Personally I enjoy working on this project more than my own schoolwork. --@RiceAbove

Feel free to contribute to the project!

๐Ÿ•น Project Motivation

Implementing the project in Java was weird, py's connect was sleek. Thus, the project stack was shifted over to Python. If you can think of any features, plugins, or functionality you wish to see in the project. Feel free to add it yourself, or create an issue detailing your ideas. We highly recommend you attempt to implement it yourself first and ask for help in our discord server !

Psst. Since I learnt py through this bot, we decided to keep a new-comers friendly policy. Feeling lost? Just ping.

โœ‚ Current Features

  • ๐Ÿฌ OOP architecture
  • ๐Ÿ›ฐ๏ธ keyword parameters
  • ๐ŸŒต password security with config file [disabled for now]
  • ๐Ÿ”Œ now with plugins

:mountain: GUI clients

GUI clients are used to manage plugins, launch bot as well as specify credentials.

โŒš Current Plugins

PluginDescriptionContributor
๐Ÿ’Ž bitcoinGet price of bitcoin@Macr0Nerd
โฒ caesar cipherEncode your text@kylegalloway
๐Ÿ”ข calcEvaluates maths expressions@Abdur-rahmaanJ
๐Ÿ“ mathsTrigonometry & random number generator@Abdur-rahmaanJ
๐Ÿƒ conv sniffSet triggers like how many times a word occur for one or more words and send response@Abdur-rahmaanJ
โ„ greetDemo plugin@Abdur-rahmaanJ
โ›“ installed_modulesChecks dependencies installed@Abdur-rahmaanJ
๐Ÿ•ถ jokeGet random joke@Abdur-rahmaanJ, @colbyjayallen
โ“ self TriviaRandom trivia@ajimenezUCLA
๐Ÿ’ข usernameUsername generator@Abdur-rahmaanJ, @sseryani
๐Ÿ“œ quotesInspirational quotes@German-Corpaz
๐Ÿ“– dictionaryReturns meaning of word@iamnishant14
๐Ÿ”ฃ password generatorThe name tells it all@iamnishant14
๐Ÿœ debugPrints all parameters passed to bot@Abdur-rahmaanJ
๐Ÿ“š wikipediaReturns a wikipedia article@Macr0Nerd
๐Ÿ—ฟ translateGoogle translate plugin@a-deeb
๐Ÿ“‘ testRuns tests@Abdur-rahmaanJ
โ›…๏ธ weatherReturns weather info for a given location@Macr0Nerd
โœ‰๏ธ mailSend emails within the chat@TannerFry
๐Ÿ•ด๏ธ hangmanPlay hangman in the chat@JustinWalker4179
๐ŸŽ‚ ageTakes in birthday and outputs age@JustinWalker4179
โœ”๏ธ factReturns a random fact@JustinWalker4179
๐Ÿ” googleReturns three search results from google@JustinWalker4179
๐Ÿ“ฎ send messageSends a message to another channel@JustinWalker4179
๐Ÿ“ logLogs the chat into a log file@RiceAbove
๐Ÿšช joinsGreets everyone who joins the channel@RiceAbove
๐Ÿ“… datePosts the current date@RiceAbove
๐Ÿ•ต๏ธโ€ riddleReturns a random riddle@AngeloGiacco
๐Ÿ—ž newsGets the top 10 headlines from bbc world news@AngeloGiacco
๐Ÿ“ horoscopeGets your daily horoscope for your starsign@AngeloGiacco
๐Ÿ’ต currency converterConverts currencies@AngeloGiacco
๐Ÿ”ซ russian_rouletteMay or may not kick you off the channel@AngeloGiacco
๐Ÿจ monopolyHoneybot now supports the world's worst game!@AngeloGiacco
โšฝ๏ธ transfer_rumourShows the day's transfer rumours@AngeloGiacco
๐Ÿƒ blackjack/21Play 21 on honeybot!@AngeloGiacco
๐Ÿค’ coronaGet the latest news on coronavirus with honeybot!@AngeloGiacco
๐Ÿ“– diaryKeep a diary with honeybot@AngeloGiacco
๐Ÿ›ฉ flightGets flight info from flightradar24@AngeloGiacco
๐ŸŽฒ rollRolls a dice@GlennToms
โ“ helpShow link to plugin's information page@edumello
โœ… channeljoinJoin command for bot@marceloyb
:page_with_curl: comicReturns a random comic@mboekhold
๐Ÿ“ todoMakes a to do list@h-ranjan1110
๐ŸŽฑ Magic 8 BallAnswer questions using magic 8 ball@ZakariaTalhami
๐ŸŽŸ Random ExcuseGenerates a random excuse for you.@rakeshseal0
๐Ÿฆ† DuckDuckGo SearchSearch queries in duckduckgo and return abstract.@rakeshseal0
๐Ÿ–ผ Random ImageReturns a random image url.@rakeshseal0
๐Ÿ›ข URL ShortenerShortens a url@rakeshseal0
๐Ÿ˜ emojiReturns emoji meaning@deadex-ng
๐ŸŽ‚ birthdayShows birthday match probability on a people group.@paulosgf
๐Ÿ€ basketballShows information about the medals of euroBasket and Basketball world cup@kefthymic
๐ŸŽฌ movies_imdbReturns certain information about a certain movie or shows 250 all time best movies@ZoeyKats
โ›ฉ๏ธ animeReturns certain information about the top 100 anime@cdkontos

โšก Quickstart

setup

mkdir botx
cd botx
python -m venv venv
venv\scripts\activate # or source venv/bin/activate for linux
python -m pip install honeybot

run

honeybot init
honeybot run

in settings/settings.toml

[INFO]

server_url = irc.libera.chat
port = 6667
name = appinventormuBot

In settings/settings.toml listed plugins under PLUGINS/downloaded will load. Plugins in directory plugins/core are auto loaded.

๐Ÿ’ป Seeing The Bot In Action

Get an IRC client

configure

port: 6667
url: irc.libera.chat

then join channel #ltch

you should see the bot as hbot ... or as it's name is in settings

Docker

Building Docker image

Change SERVER, PORT and NICKNAME variables to match your preferences

docker build -t "honeybot/honeybot:6.0.2" .

Running Docker image

docker run -d --name=honeybot honeybot/honeybot:v6.0.2 honeybot run

๐Ÿ”ง Plugins Development

Each plugin has a folder named after it. In it there is a file called main.py. In each there is a class called Plugin.

# -*- coding: utf-8 -*-

class Plugin:
    def __init__(self):
        pass

    def run(self, incoming, methods, info, bot_info):
        try:
            if info['command'] == 'PRIVMSG' and info['args'][1] == '.hi':
                methods['send'](info['address'], 'hooo')
        except Exception as e:
            print('woops plugin error ', e)

we see four parameters being passed to the run method , incoming, methods, info, bot_info)

parameter1: incoming

incoming is the raw line and is not used except if you are not satisfied with the already provided methods

parameter2: methods

methods is a dictionary of methods to ease your life. a quick look at main.py reveals

def methods(self):
        return {
                'send_raw': self.send,
                'send': self.send_target,
                'join': self.join
                }

where send_raw allows you to send in any string you want, thereby allowing you to implement any irc protocol from scratch

but, for most uses, send allows you to send a message to an address methods['send']('<address>', '<message>'). using it in conjunction with info parameter allows you to send messages where it came from, in pm to the bot or in a channel. you can however hardcode the address.

join allows you to join a channel by methods['join']('<channel name>')

parameter3: info (meaning message info)

for a normal run, info produces

{
'prefix': 'appinv!c5e342c5@gateway/web/cgi-irc/kiwiirc.com/ip.200.200.22.200',
'command': 'PRIVMSG',
'address': '##bottestingmu',
'args': ['##bottestingmu', 'ef']
}

hence if you want messages, messages = info['args'][1:] or the first word if you want to check for command will be info['args'][1]

use example

  • the command info is used in the join channel plugin to detect a join command and greet the user who just joined

bot info

bot_info returns info about the bot

        return {
            'name': self.name,
            'special_command': self.sp_command,
            'required_modules': self.required_modules,
            'owners': self.owners,
            'time': self.time,
            'friends': self.friends
        }

so that in run method you can access those.

use example

  • For example, the time info is used in the uptime plugin by minussing it from the current time to get time bot has been running.
  • The required modules is used in the installed plugin to determine what required plugin the bot runner did not install

wrapping up

hence

if info['command'] == 'PRIVMSG' and info['args'][1] == '.hi':
    methods['send'](info['address'], 'hooo')

from above means

if message received == .hi:
    send(address, message)

๐Ÿ“ƒ Contributing Guide

https://pyhoneybot.github.io/honeybot/How_Tos/contributing.html

  • don't forget to add your country flag here after accepted PR. i'll have to hunt it down on your profile if not.
  • make sure to follow PEP8

Check out Contributing to get started on contributing.

๐Ÿ”Œ Todo Plugins

  • ๐Ÿ’ humour
  • ๐ŸŒจ๏ธ weather
  • โœ‰๏ธ mail
  • ๐ŸŽ›๏ธ maths
  • ๐Ÿ“ฅ pm when user online
  • Random Colour

โ˜‘ Allowing Plugins

Plugins available https://pyhoneybot.github.io/honeybot/plugins.html

in settings/settings.toml, add the plugin to allow!

[PLUGINS]

downloaded = ["greet",] # Downloaded plugins to load

๐Ÿ“ง Contact (Including vulnerabilities)

Email

๐Ÿ–Š Credits

  • @arwinneil, "Open Source" and "Made In Moris" badges