From b1b3606ae4b79dac44fb350d995ee28135ad9634 Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 19 Oct 2015 20:28:57 -0400 Subject: [PATCH] Added prompted command to make the bot respond whenever its name is mentioned --- lib/pyborg/pyborg-irc.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/pyborg/pyborg-irc.py b/lib/pyborg/pyborg-irc.py index 190d3cf..5820f18 100755 --- a/lib/pyborg/pyborg-irc.py +++ b/lib/pyborg/pyborg-irc.py @@ -92,6 +92,7 @@ class ModIRC(SingleServerIRCBot): "me": "Owner command. Usage !me nick message\nmake the bot send the sentence 'message' to 'nick'", "jump": "Owner command. Usage: !jump\nMake the bot reconnect to IRC", "quit": "Owner command. Usage: !quit\nMake the bot quit IRC", + "prompted": "Owner command. Usage: !prompted [on|off]\nTurn prompted mode on or off (bot will respond every time a message contains its name)", "owner": "Usage: !owner password\nAllow to become owner of the bot" } @@ -118,6 +119,7 @@ def __init__(self, my_pyborg, args): "reply2ignored": ("Reply to ignored people", 0), "reply_chance": ("Chance of reply (%) per message", 33), "quitmsg": ("IRC quit message", "Bye :-("), + "prompted": ("Respond whenever bot name is mentioned", 0), "password": ("password for control the bot (Edit manually !)", ""), "autosaveperiod": ("Save every X minutes. Leave at 0 for no saving.", 60), "nickserv": ("username and password for nickserv", ("", "")) @@ -366,6 +368,9 @@ def on_msg(self, c, e): # double reply chance if the text contains our nickname :-) if body_contains_me: replyrate = replyrate * 2 + # always respond if prompted is true as well + if self.settings.prompted == 1: + replyrate = 100 # Always reply to private messages if e.eventtype() == "privmsg": @@ -453,6 +458,24 @@ def irc_commands(self, body, source, target, c, e): else: msg = msg + "off" self.settings.reply2ignored = 0 + + # prompted mode + elif command_list[0] == "!prompted": + msg = "Prompted mode " + if len(command_list) == 1: + if self.settings.prompted == 0: + msg = msg + "off" + else: + msg = msg + "on" + else: + toggle = command_list[1].lower() + if toggle == "on": + msg = msg + "on" + self.settings.prompted = 1 + else: + msg = msg + "off" + self.settings.prompted = 0 + # Stop talking elif command_list[0] == "!shutup": if self.settings.speaking == 1: