convert ircplugin users of privmsg to reply

bss/dr.botzo#21
This commit is contained in:
Brian S. Stephan 2017-02-12 11:39:04 -06:00
parent 23bb5cdd78
commit 6cb3757ef9
3 changed files with 34 additions and 24 deletions

View File

@ -143,7 +143,8 @@ class Acro(Plugin):
self.game.state = 1
self.game.channel = channel
self.bot.privmsg(self.game.channel, "starting a new game of acro. it will run until you tell it to quit.")
self.bot.reply(None, "starting a new game of acro. it will run until you tell it to quit.",
explicit_target=self.game.channel)
self._start_new_round()
@ -156,8 +157,9 @@ class Acro(Plugin):
self.game.rounds[-1].acro = acro
sleep_time = self.game.rounds[-1].seconds_to_submit + (self.game.rounds[-1].seconds_to_submit_step * (len(acro)-3))
self.bot.privmsg(self.game.channel, "the round has started! your acronym is '{0:s}'. "
"submit within {1:d} seconds via !acro submit [meaning]".format(acro, sleep_time))
self.bot.reply(None, "the round has started! your acronym is '{0:s}'. "
"submit within {1:d} seconds via !acro submit [meaning]".format(acro, sleep_time),
explicit_target=self.game.channel)
t = threading.Thread(target=self.thread_do_process_submissions, args=(sleep_time,))
t.daemon = True
@ -258,7 +260,7 @@ class Acro(Plugin):
self.game.state = 3
self.game.rounds[-1].sub_shuffle = list(self.game.rounds[-1].submissions.keys())
random.shuffle(self.game.rounds[-1].sub_shuffle)
self.bot.privmsg(self.game.channel, "here are the results. vote with !acro vote [number]")
self.bot.reply(None, "here are the results. vote with !acro vote [number]", explicit_target=self.game.channel)
self._print_round_acros()
t = threading.Thread(target=self.thread_do_process_votes, args=())
@ -271,7 +273,8 @@ class Acro(Plugin):
i = 0
for s in self.game.rounds[-1].sub_shuffle:
log.debug("%s is %s", str(i), s)
self.bot.privmsg(self.game.channel, " {0:d}: {1:s}".format(i+1, self.game.rounds[-1].submissions[s]))
self.bot.reply(None, " {0:d}: {1:s}".format(i+1, self.game.rounds[-1].submissions[s]),
explicit_target=self.game.channel)
i += 1
def _take_acro_vote(self, nick, vote):
@ -295,7 +298,7 @@ class Acro(Plugin):
"""Clean up and output for ending the current round."""
self.game.state = 4
self.bot.privmsg(self.game.channel, "voting's over! here are the scores for the round:")
self.bot.reply(None, "voting's over! here are the scores for the round:", explicit_target=self.game.channel)
self._print_round_scores()
self._add_round_scores_to_game_scores()
@ -309,7 +312,8 @@ class Acro(Plugin):
i = 0
for s in list(self.game.rounds[-1].submissions.keys()):
votes = [x for x in list(self.game.rounds[-1].votes.values()) if x == s]
self.bot.privmsg(self.game.channel, " {0:d} ({1:s}): {2:d}".format(i+1, s, len(votes)))
self.bot.reply(None, " {0:d} ({1:s}): {2:d}".format(i+1, s, len(votes)),
explicit_target=self.game.channel)
i += 1
def _add_round_scores_to_game_scores(self):
@ -336,14 +340,14 @@ class Acro(Plugin):
self.game.state = 0
self.game.quit = False
self.bot.privmsg(self.game.channel, "game's over! here are the final scores:")
self.bot.reply(None, "game's over! here are the final scores:", explicit_target=self.game.channel)
self._print_game_scores()
def _print_game_scores(self):
"""Print the final calculated scores."""
for s in list(self.game.scores.keys()):
self.bot.privmsg(self.game.channel, " {0:s}: {1:d}".format(s, self.game.scores[s]))
self.bot.reply(None, " {0:s}: {1:d}".format(s, self.game.scores[s]), explicit_target=self.game.channel)
plugin = Acro

View File

@ -133,8 +133,9 @@ class Storycraft(Plugin):
player = StorycraftPlayer.objects.create(nick=nick, nickmask=event.source, game=game)
# tell the control channel
self.bot.privmsg(master_channel, "{0:s} created a game of storycraft - do '!storycraft game "
"{1:d} join' to take part!".format(nick, game.pk))
self.bot.reply(None, "{0:s} created a game of storycraft - do '!storycraft game "
"{1:d} join' to take part!".format(nick, game.pk),
explicit_target=master_channel)
log.debug("%s added a new game", nick)
return self.bot.reply(event, "Game #{0:d} has been created. When everyone has joined, do "
@ -163,7 +164,8 @@ class Storycraft(Plugin):
# output results
master_channel = settings.STORYCRAFT_MASTER_CHANNEL
self.bot.privmsg(master_channel, "{0:s} joined storycraft #{1:d}!".format(nick, game_id))
self.bot.reply(None, "{0:s} joined storycraft #{1:d}!".format(nick, game_id),
explicit_target=master_channel)
log.debug("%s joined game #%d", nick, game_id)
return self.bot.reply(event, "{0:s}, welcome to the game.".format(nick))
else:
@ -235,9 +237,10 @@ class Storycraft(Plugin):
master_channel = settings.STORYCRAFT_MASTER_CHANNEL
# tell the control channel
self.bot.privmsg(master_channel, "{0:s} started storycraft #{1:d}! - first player "
self.bot.reply(None, "{0:s} started storycraft #{1:d}! - first player "
"is {2:s}, do '!storycraft game {1:d} show line' when the game is "
"assigned to you.".format(nick, game_id, player.nick))
"assigned to you.".format(nick, game_id, player.nick),
explicit_target=master_channel)
log.debug("%s started game #%d", nick, game_id)
return self.bot.reply(event, "Game #{0:d} started.".format(game_id))
@ -343,22 +346,25 @@ class Storycraft(Plugin):
return_msg = 'Line logged. Please add another. ' + progress_str
else:
# notify the new owner, too
self.bot.privmsg(player.nick, "You have a new line in storycraft "
self.bot.reply(None, "You have a new line in storycraft "
"#{0:d}: '{1:s}' {2:s}"
"".format(game_id, last_line.line, progress_str))
"".format(game_id, last_line.line, progress_str),
explicit_target=player.nick)
master_channel = settings.STORYCRAFT_MASTER_CHANNEL
log.debug("%s added a line to #%d", nick, game_id)
# log output
if game.status == StorycraftGame.STATUS_IN_PROGRESS:
self.bot.privmsg(master_channel, "{0:s} added a line to storycraft "
self.bot.reply(None, "{0:s} added a line to storycraft "
"#{1:d}! - next player is {2:s}"
"".format(nick, game_id, player.nick))
"".format(nick, game_id, player.nick),
explicit_target=master_channel)
return self.bot.reply(event, return_msg)
else:
self.bot.privmsg(master_channel, "{0:s} finished storycraft #{1:d}!"
"".format(nick, game_id))
self.bot.reply(None, "{0:s} finished storycraft #{1:d}!"
"".format(nick, game_id),
explicit_target=master_channel)
return self.bot.reply(event, "Line logged (and game completed).")
else:
return self.bot.reply(event, "Failed to assign game to next player.")

View File

@ -276,7 +276,7 @@ class Twitter(Plugin):
mentions.reverse()
for mention in mentions:
reply = self._return_tweet_or_retweet_text(tweet=mention, print_source=True)
self.bot.privmsg(out_chan, reply)
self.bot.reply(None, reply, explicit_target=out_chan)
since_id = mention['id'] if mention['id'] > since_id else since_id
twittersettings.mentions_since_id = since_id