rename Module.new_sendmsg() -> Module.sendmsg()

remove the deprecated method as well, of course
This commit is contained in:
Brian S. Stephan 2013-02-09 15:11:38 -06:00
parent c7d78ba6fc
commit 9b7cbadce6
7 changed files with 21 additions and 39 deletions

View File

@ -124,27 +124,9 @@ class Module(object):
return self.do(connection, event, nick, userhost, what, admin_unlocked)
def sendmsg(self, connection, target, msg):
def sendmsg(self, target, msg):
"""Send a privmsg over IRC to target.
Args:
connection server connection to send the message to
target destination on the network
msg the message to send
"""
if msg is not None:
if target is not None:
msgs = msg.split('\n')
for line in msgs:
connection.privmsg(target, line)
def new_sendmsg(self, target, msg):
"""Send a privmsg over IRC to target.
This should replace Module.sendmsg() once all code has been converted.
Args:
target destination on the network
msg the message to send

View File

@ -421,7 +421,7 @@ class Achievements(Module):
channel = settings.channel
achievers = self._query_for_new_achievers()
for achiever in achievers:
self.new_sendmsg(channel, achiever[0] + ' achieved ' + achiever[1] + '!')
self.sendmsg(channel, achiever[0] + ' achieved ' + achiever[1] + '!')
def _query_for_new_achievers(self):
"""Get new achievement earners for each achievement."""

View File

@ -157,7 +157,7 @@ class Acro(Module):
self.game.state = 1
self.game.channel = channel
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
"starting a new game of acro. it will run until you tell it to quit.")
self._start_new_round()
@ -171,7 +171,7 @@ class Acro(Module):
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.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
"the round has started! your acronym is '{0:s}'. ".format(acro) +
"submit within {0:d} seconds via !acro submit [meaning]".format(sleep_time))
@ -271,7 +271,7 @@ class Acro(Module):
self.game.state = 3
self.game.rounds[-1].sub_shuffle = self.game.rounds[-1].submissions.keys()
random.shuffle(self.game.rounds[-1].sub_shuffle)
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
"here are the results. vote with !acro vote [number]")
self._print_round_acros()
@ -283,7 +283,7 @@ class Acro(Module):
i = 0
for s in self.game.rounds[-1].sub_shuffle:
self.log.debug(str(i) + " is " + s)
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
" {0:d}: {1:s}".format(i+1, self.game.rounds[-1].submissions[s]))
i += 1
@ -308,7 +308,7 @@ class Acro(Module):
"""Clean up and output for ending the current round."""
self.game.state = 4
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
"voting's over! here are the scores for the round:")
self._print_round_scores()
self._add_round_scores_to_game_scores()
@ -323,7 +323,7 @@ class Acro(Module):
i = 0
for s in self.game.rounds[-1].submissions.keys():
votes = filter(lambda x: x == s, self.game.rounds[-1].votes.values())
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
" {0:d} ({1:s}): {2:d}".format(i+1, s, len(votes)))
i += 1
@ -351,7 +351,7 @@ class Acro(Module):
self.game.state = 0
self.game.quit = False
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
"game's over! here are the final scores:")
self._print_game_scores()
@ -359,7 +359,7 @@ class Acro(Module):
"""Print the final calculated scores."""
for s in self.game.scores.keys():
self.new_sendmsg(self.game.channel,
self.sendmsg(self.game.channel,
" {0:s}: {1:d}".format(s, self.game.scores[s]))
# vi:tabstop=4:expandtab:autoindent

View File

@ -86,7 +86,7 @@ class Dispatch(Module):
if key is not None and dest is not None:
msg = "[{0:s}] {1:s}".format(key, message.encode('utf-8', 'ignore'))
self.new_sendmsg(dest, msg)
self.sendmsg(dest, msg)
return dest, msg

View File

@ -259,7 +259,7 @@ class Markov(Module):
if t['chance'] > 0:
a = random.randint(1, t['chance'])
if a == 1:
self.new_sendmsg(t['target'], self._generate_line(t['target']))
self.sendmsg(t['target'], self._generate_line(t['target']))
def _do_shut_up_checks(self):
"""Check to see if we've been talking too much, and shut up if so."""
@ -282,7 +282,7 @@ class Markov(Module):
self.shut_up = True
targets = self._get_chatter_targets()
for t in targets:
self.new_sendmsg(t['target'],
self.sendmsg(t['target'],
'shutting up for 30 seconds due to last 30 seconds of activity')
def _learn_line(self, line, target, event):

View File

@ -267,7 +267,7 @@ class Storycraft(Module):
self._add_player_to_game(game_id, nick, userhost)
# tell the control channel
self.new_sendmsg(master_channel, '{0:s} created a game of storycraft - do \'!storycraft game {1:d} join\' to take part!'.format(nick, game_id))
self.sendmsg(master_channel, '{0:s} created a game of storycraft - do \'!storycraft game {1:d} join\' to take part!'.format(nick, game_id))
self.log.debug("{0:s} added a new game".format(nick))
return 'Game #{0:d} has been created. When everyone has joined, do \'!storycraft game {0:d} start\''.format(game_id)
@ -298,7 +298,7 @@ class Storycraft(Module):
settings = self._get_storycraft_settings()
master_channel = settings.master_channel
self.new_sendmsg(master_channel, '{0:s} joined storycraft #{1:d}!'.format(nick, game_id))
self.sendmsg(master_channel, '{0:s} joined storycraft #{1:d}!'.format(nick, game_id))
self.log.debug("{0:s} joined game #{1:d}".format(nick, game_id))
return '{0:s}, welcome to the game.'.format(nick)
else:
@ -371,7 +371,7 @@ class Storycraft(Module):
master_channel = settings.master_channel
# tell the control channel
self.new_sendmsg(master_channel, '{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))
self.sendmsg(master_channel, '{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))
self.log.debug("{0:s} started game #{1:d}".format(nick, game_id))
return 'Game #{0:d} started.'.format(game_id)
@ -473,7 +473,7 @@ class Storycraft(Module):
return_msg = 'Line logged. Please add another. ' + progress_str
else:
# notify the new owner, too
self.new_sendmsg(player.nick, 'You have a new line in storycraft #{0:d}: \'{1:s}\' {2:s}'.format(game_id, last_line.line, progress_str))
self.sendmsg(player.nick, 'You have a new line in storycraft #{0:d}: \'{1:s}\' {2:s}'.format(game_id, last_line.line, progress_str))
# get the default settings
settings = self._get_storycraft_settings()
@ -482,10 +482,10 @@ class Storycraft(Module):
self.log.debug("{0:s} added a line to #{1:d}".format(nick, game_id))
# log output
if game.status == 'IN PROGRESS':
self.new_sendmsg(master_channel, '{0:s} added a line to storycraft #{1:d}! - next player is {2:s}'.format(nick, game_id, player.nick))
self.sendmsg(master_channel, '{0:s} added a line to storycraft #{1:d}! - next player is {2:s}'.format(nick, game_id, player.nick))
return return_msg
else:
self.new_sendmsg(master_channel, '{0:s} finished storycraft #{1:d}!'.format(nick, game_id))
self.sendmsg(master_channel, '{0:s} finished storycraft #{1:d}!'.format(nick, game_id))
return 'Line logged (and game completed).'
else:
return 'Failed to assign game to next player.'

View File

@ -328,7 +328,7 @@ class Twitter(Module):
#tweets.reverse()
#for tweet in tweets:
# tweet_text = self._return_tweet_or_retweet_text(tweet=tweet, print_source=True)
# self.new_sendmsg(output_channel.encode('utf-8', 'ignore'), tweet_text)
# self.sendmsg(output_channel.encode('utf-8', 'ignore'), tweet_text)
#
## friends timeline printed, find the latest id
#new_since_id = self._get_latest_tweet_id(tweets, since_id)
@ -337,7 +337,7 @@ class Twitter(Module):
tweets.reverse()
for tweet in tweets:
tweet_text = self._return_tweet_or_retweet_text(tweet=tweet, print_source=True)
self.new_sendmsg(output_channel.encode('utf-8', 'ignore'), tweet_text)
self.sendmsg(output_channel.encode('utf-8', 'ignore'), tweet_text)
# mentions printed, find the latest id
new_since_id = self._get_latest_tweet_id(tweets, new_since_id)