Add nickserv plugin
This allows the bot to register itself and login. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
50
plugins/nickserv.py
Normal file
50
plugins/nickserv.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
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
|
||||||
Reference in New Issue
Block a user