Files
omnibot22/plugins/nickserv.py
Alek Ratzloff 56e99c237b Add nickserv plugin
This allows the bot to register itself and login.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 19:45:49 -07:00

51 lines
1.3 KiB
Python

import logging
from typing import Sequence
from asyncirc.protocol import IrcProtocol
from irclib.parser import Message, Prefix
from omnibot.plugin import Plugin
log = logging.getLogger(__name__)
class NickServ(Plugin):
def get_message_types(self) -> Sequence[str]:
return ["001"]
@property
def password(self) -> str:
return self.plugin_config["password"]
@property
def email(self) -> str:
return self.plugin_config.get("email", "omnibot@omni.bot")
@property
def nickserv(self) -> str:
return self.plugin_config.get("nickserv", "NickServ")
async def on_message(self, conn: IrcProtocol, channel: str, who: Prefix, line: str):
# XXX : channel is the wrong nomenclature here and kind of an artifact of the API design
log.info("Registering with NickServ")
self.send_message(
conn,
Message(
None,
None,
"PRIVMSG",
self.nickserv,
"register",
self.password,
self.email,
),
)
log.info("Authenticating with NickServ")
self.send_message(
conn,
Message(None, None, "PRIVMSG", self.nickserv, "identify", self.password),
)
PLUGIN_TYPE = NickServ