Skip to content

An IRC bot with plugin. ignited in mauritius, powered by python.

License

Notifications You must be signed in to change notification settings

ajimenezUCLA/honeybot

 
 

Repository files navigation

first-timers-only Open Source Love MadeinMoris

🍯 honeybot py

📮 About

HoneyBot is a python-based IRC bot.

Feel free to contribute to the project!

alt text

🕹 Project Motivation

Implementing the project in Java was a nightmare, 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 slack page!

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

📌 Contributing Countries

🇲🇺 🇺🇸 🇨🇦 🇦🇷

✂ Current Features

  • 👋 Greeting
  • 🍬 OOP architecture
  • 🛰️ keyword parameters
  • 🌵 password security with config file [disabled for now]
  • 🔌 now with plugins
  • 📜 Quotes
  • 🧠 Self Trivia

📜 Contributing Guide

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

🔧 Plugins Development

including it here. let's begin

a plugin has the following structure:

# -*- coding: utf-8 -*-
"""
[greet.py]
Greet Plugin
[Author]
Abdur-Rahmaan Janhangeer, pythonmembers.club
[About]
responds to .hi, demo of a basic plugin
[Commands]
>>> .hi
returns hoo
"""


class Plugin:
    def __init__(self):
        pass

    def run(self, incoming, methods, 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 three parameters being passed to the run method , incoming, methods, 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

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]

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)

⚡ Quickstart

  • specify your details in CONNECT.conf (already included)
[INFO]

server_url = chat.freenode.net
port = 6667
name = appinventormuBot
  • run main.py

🔌 Todo Plugins

  • 💐 humour
  • 🌨️ weather
  • ✉️ mail
  • 🎛️ maths
  • 📥 pm when user online

☑ Allowing Plugins

in PLUGINS.conf, add the plugin to allow on a new line !

calc
username

📧 Contact

Email

Slack

https://honeybotworkspace.slack.com/messages/CGQLHMNCE/

🖊 Credits

@arwinneil for opensource and madeinmoris badges

Follow the project on CodeTriage for updates!

Open Source Helpers

About

An IRC bot with plugin. ignited in mauritius, powered by python.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%