|
|
@ -6,6 +6,7 @@ import logging |
|
|
|
import tools.moduleloader as ld |
|
|
|
import tools.moduleloader as ld |
|
|
|
import traceback |
|
|
|
import traceback |
|
|
|
from settings import common as var |
|
|
|
from settings import common as var |
|
|
|
|
|
|
|
from base64 import b64encode |
|
|
|
|
|
|
|
|
|
|
|
def on_privmsg(cli, rawnick, chan, msg, notice = False): |
|
|
|
def on_privmsg(cli, rawnick, chan, msg, notice = False): |
|
|
|
currmod = ld.MODULES[ld.CURRENT_MODULE] |
|
|
|
currmod = ld.MODULES[ld.CURRENT_MODULE] |
|
|
@ -94,9 +95,6 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False) |
|
|
|
|
|
|
|
|
|
|
|
def connect_callback(cli): |
|
|
|
def connect_callback(cli): |
|
|
|
|
|
|
|
|
|
|
|
identified = False |
|
|
|
|
|
|
|
need_ghost = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prepare_stuff(*args): |
|
|
|
def prepare_stuff(*args): |
|
|
|
cli.join(botconfig.CHANNEL) |
|
|
|
cli.join(botconfig.CHANNEL) |
|
|
|
cli.msg("ChanServ", "op "+botconfig.CHANNEL) |
|
|
|
cli.msg("ChanServ", "op "+botconfig.CHANNEL) |
|
|
@ -106,66 +104,55 @@ def connect_callback(cli): |
|
|
|
|
|
|
|
|
|
|
|
ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli) |
|
|
|
ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli) |
|
|
|
|
|
|
|
|
|
|
|
cli.nick(botconfig.NICK) # just in case |
|
|
|
cli.nick(botconfig.NICK) # very important (for regain/release) |
|
|
|
|
|
|
|
|
|
|
|
if botconfig.JOIN_AFTER_CLOAKED: |
|
|
|
|
|
|
|
prepare_stuff = hook("event_hosthidden", hookid=294)(prepare_stuff) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@hook("mode") |
|
|
|
|
|
|
|
def check_if_identified(cli, spam, egg, m, *etc): |
|
|
|
|
|
|
|
if m == "+i": |
|
|
|
|
|
|
|
identified = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@hook("nicknameinuse") |
|
|
|
|
|
|
|
def mustghost(cli, *blah): |
|
|
|
|
|
|
|
cli.ns_identify(cli.password) |
|
|
|
|
|
|
|
cli.nick(botconfig.NICK+"_") |
|
|
|
|
|
|
|
if identified: |
|
|
|
|
|
|
|
cli.ns_ghost() |
|
|
|
|
|
|
|
cli.nick(botconfig.NICK) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
@hook("mode") |
|
|
|
|
|
|
|
def do_ghost(cli, spam, egg, m, *etc): |
|
|
|
|
|
|
|
if m == "+i": |
|
|
|
|
|
|
|
cli.ns_ghost() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not botconfig.JOIN_AFTER_CLOAKED: |
|
|
|
prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff) |
|
|
|
prepare_stuff(cli) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@hook("quit", hookid=232) |
|
|
|
def mustregain(cli, *blah): |
|
|
|
def after_ghost(cli, nick, reason): |
|
|
|
cli.ns_regain() |
|
|
|
if nick == botconfig.NICK and reason == "Disconnected by services": |
|
|
|
|
|
|
|
cli.nick(botconfig.NICK) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decorators.unhook(HOOKS, 232) |
|
|
|
def mustrelease(cli, *rest): |
|
|
|
|
|
|
|
cli.ns_release() |
|
|
|
|
|
|
|
cli.nick(botconfig.NICK) |
|
|
|
|
|
|
|
|
|
|
|
@hook("unavailresource") |
|
|
|
@hook("unavailresource", hookid=239) |
|
|
|
def mustrelease(cli, *blah): |
|
|
|
@hook("nicknameinuse", hookid=239) |
|
|
|
cli.ns_identify(cli.password) |
|
|
|
def must_use_temp_nick(cli, *etc): |
|
|
|
cli.nick(botconfig.NICK+"_") |
|
|
|
cli.nick(botconfig.NICK+"_") |
|
|
|
if identified: |
|
|
|
cli.user(botconfig.NICK, "") |
|
|
|
cli.ns_release() |
|
|
|
|
|
|
|
cli.nick(botconfig.NICK) |
|
|
|
decorators.unhook(HOOKS, 239) |
|
|
|
else: |
|
|
|
hook("unavailresource")(mustrelease) |
|
|
|
@hook("mode") |
|
|
|
hook("nicknameinuse")(mustregain) |
|
|
|
def do_release(cli, spam, egg, m, *etc): |
|
|
|
|
|
|
|
if m == "+i": |
|
|
|
if botconfig.SASL_AUTHENTICATION: |
|
|
|
cli.ns_release() |
|
|
|
|
|
|
|
|
|
|
|
@hook("authenticate") |
|
|
|
if not botconfig.JOIN_AFTER_CLOAKED: |
|
|
|
def auth_plus(cli, something, plus): |
|
|
|
prepare_stuff(cli) |
|
|
|
if plus == "+": |
|
|
|
|
|
|
|
nick_b = bytes(botconfig.USERNAME if botconfig.USERNAME else botconfig.NICK, "utf-8") |
|
|
|
@hook("notice", hookid=233) |
|
|
|
pass_b = bytes(botconfig.PASS, "utf-8") |
|
|
|
def after_release(cli, *etc): #hopefully this works |
|
|
|
secrt_msg = b'\0'.join((nick_b, nick_b, pass_b)) |
|
|
|
cli.nick(botconfig.NICK) |
|
|
|
print(secrt_msg) |
|
|
|
|
|
|
|
cli.send("AUTHENTICATE " + b64encode(secrt_msg).decode("utf-8")) |
|
|
|
decorators.unhook(HOOKS, 233) |
|
|
|
|
|
|
|
|
|
|
|
@hook("cap") |
|
|
|
if not botconfig.JOIN_AFTER_CLOAKED: # join immediately |
|
|
|
def on_cap(cli, svr, mynick, ack, cap): |
|
|
|
pass |
|
|
|
if ack.upper() == "ACK" and "sasl" in cap: |
|
|
|
# prepare_stuff(cli) |
|
|
|
cli.send("AUTHENTICATE PLAIN") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@hook("903") |
|
|
|
|
|
|
|
def on_successful_auth(cli, blah, blahh, blahhh): |
|
|
|
|
|
|
|
cli.cap("END") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@hook("904") |
|
|
|
|
|
|
|
@hook("905") |
|
|
|
|
|
|
|
@hook("906") |
|
|
|
|
|
|
|
@hook("907") |
|
|
|
|
|
|
|
def on_failure_auth(cli, *etc): |
|
|
|
|
|
|
|
cli.quit() |
|
|
|
|
|
|
|
print("Authentication failed. Did you fill the account name "+ |
|
|
|
|
|
|
|
"in botconfig.USERNAME if it's different from the bot nick?") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|