rename Module.new_sendmsg() -> Module.sendmsg()
remove the deprecated method as well, of course
This commit is contained in:
parent
c7d78ba6fc
commit
9b7cbadce6
20
Module.py
20
Module.py
|
@ -124,27 +124,9 @@ class Module(object):
|
||||||
|
|
||||||
return self.do(connection, event, nick, userhost, what, admin_unlocked)
|
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.
|
"""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:
|
Args:
|
||||||
target destination on the network
|
target destination on the network
|
||||||
msg the message to send
|
msg the message to send
|
||||||
|
|
|
@ -421,7 +421,7 @@ class Achievements(Module):
|
||||||
channel = settings.channel
|
channel = settings.channel
|
||||||
achievers = self._query_for_new_achievers()
|
achievers = self._query_for_new_achievers()
|
||||||
for achiever in 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):
|
def _query_for_new_achievers(self):
|
||||||
"""Get new achievement earners for each achievement."""
|
"""Get new achievement earners for each achievement."""
|
||||||
|
|
|
@ -157,7 +157,7 @@ class Acro(Module):
|
||||||
|
|
||||||
self.game.state = 1
|
self.game.state = 1
|
||||||
self.game.channel = channel
|
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.")
|
"starting a new game of acro. it will run until you tell it to quit.")
|
||||||
|
|
||||||
self._start_new_round()
|
self._start_new_round()
|
||||||
|
@ -171,7 +171,7 @@ class Acro(Module):
|
||||||
self.game.rounds[-1].acro = acro
|
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))
|
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) +
|
"the round has started! your acronym is '{0:s}'. ".format(acro) +
|
||||||
"submit within {0:d} seconds via !acro submit [meaning]".format(sleep_time))
|
"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.state = 3
|
||||||
self.game.rounds[-1].sub_shuffle = self.game.rounds[-1].submissions.keys()
|
self.game.rounds[-1].sub_shuffle = self.game.rounds[-1].submissions.keys()
|
||||||
random.shuffle(self.game.rounds[-1].sub_shuffle)
|
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]")
|
"here are the results. vote with !acro vote [number]")
|
||||||
self._print_round_acros()
|
self._print_round_acros()
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ class Acro(Module):
|
||||||
i = 0
|
i = 0
|
||||||
for s in self.game.rounds[-1].sub_shuffle:
|
for s in self.game.rounds[-1].sub_shuffle:
|
||||||
self.log.debug(str(i) + " is " + s)
|
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]))
|
" {0:d}: {1:s}".format(i+1, self.game.rounds[-1].submissions[s]))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ class Acro(Module):
|
||||||
"""Clean up and output for ending the current round."""
|
"""Clean up and output for ending the current round."""
|
||||||
|
|
||||||
self.game.state = 4
|
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:")
|
"voting's over! here are the scores for the round:")
|
||||||
self._print_round_scores()
|
self._print_round_scores()
|
||||||
self._add_round_scores_to_game_scores()
|
self._add_round_scores_to_game_scores()
|
||||||
|
@ -323,7 +323,7 @@ class Acro(Module):
|
||||||
i = 0
|
i = 0
|
||||||
for s in self.game.rounds[-1].submissions.keys():
|
for s in self.game.rounds[-1].submissions.keys():
|
||||||
votes = filter(lambda x: x == s, self.game.rounds[-1].votes.values())
|
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)))
|
" {0:d} ({1:s}): {2:d}".format(i+1, s, len(votes)))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ class Acro(Module):
|
||||||
|
|
||||||
self.game.state = 0
|
self.game.state = 0
|
||||||
self.game.quit = False
|
self.game.quit = False
|
||||||
self.new_sendmsg(self.game.channel,
|
self.sendmsg(self.game.channel,
|
||||||
"game's over! here are the final scores:")
|
"game's over! here are the final scores:")
|
||||||
self._print_game_scores()
|
self._print_game_scores()
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ class Acro(Module):
|
||||||
"""Print the final calculated scores."""
|
"""Print the final calculated scores."""
|
||||||
|
|
||||||
for s in self.game.scores.keys():
|
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]))
|
" {0:s}: {1:d}".format(s, self.game.scores[s]))
|
||||||
|
|
||||||
# vi:tabstop=4:expandtab:autoindent
|
# vi:tabstop=4:expandtab:autoindent
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Dispatch(Module):
|
||||||
|
|
||||||
if key is not None and dest is not None:
|
if key is not None and dest is not None:
|
||||||
msg = "[{0:s}] {1:s}".format(key, message.encode('utf-8', 'ignore'))
|
msg = "[{0:s}] {1:s}".format(key, message.encode('utf-8', 'ignore'))
|
||||||
self.new_sendmsg(dest, msg)
|
self.sendmsg(dest, msg)
|
||||||
|
|
||||||
return dest, msg
|
return dest, msg
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ class Markov(Module):
|
||||||
if t['chance'] > 0:
|
if t['chance'] > 0:
|
||||||
a = random.randint(1, t['chance'])
|
a = random.randint(1, t['chance'])
|
||||||
if a == 1:
|
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):
|
def _do_shut_up_checks(self):
|
||||||
"""Check to see if we've been talking too much, and shut up if so."""
|
"""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
|
self.shut_up = True
|
||||||
targets = self._get_chatter_targets()
|
targets = self._get_chatter_targets()
|
||||||
for t in 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')
|
'shutting up for 30 seconds due to last 30 seconds of activity')
|
||||||
|
|
||||||
def _learn_line(self, line, target, event):
|
def _learn_line(self, line, target, event):
|
||||||
|
|
|
@ -267,7 +267,7 @@ class Storycraft(Module):
|
||||||
self._add_player_to_game(game_id, nick, userhost)
|
self._add_player_to_game(game_id, nick, userhost)
|
||||||
|
|
||||||
# tell the control channel
|
# 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))
|
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)
|
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()
|
settings = self._get_storycraft_settings()
|
||||||
master_channel = settings.master_channel
|
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))
|
self.log.debug("{0:s} joined game #{1:d}".format(nick, game_id))
|
||||||
return '{0:s}, welcome to the game.'.format(nick)
|
return '{0:s}, welcome to the game.'.format(nick)
|
||||||
else:
|
else:
|
||||||
|
@ -371,7 +371,7 @@ class Storycraft(Module):
|
||||||
master_channel = settings.master_channel
|
master_channel = settings.master_channel
|
||||||
|
|
||||||
# tell the control 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))
|
self.log.debug("{0:s} started game #{1:d}".format(nick, game_id))
|
||||||
|
|
||||||
return 'Game #{0:d} started.'.format(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
|
return_msg = 'Line logged. Please add another. ' + progress_str
|
||||||
else:
|
else:
|
||||||
# notify the new owner, too
|
# 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
|
# get the default settings
|
||||||
settings = self._get_storycraft_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))
|
self.log.debug("{0:s} added a line to #{1:d}".format(nick, game_id))
|
||||||
# log output
|
# log output
|
||||||
if game.status == 'IN PROGRESS':
|
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
|
return return_msg
|
||||||
else:
|
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).'
|
return 'Line logged (and game completed).'
|
||||||
else:
|
else:
|
||||||
return 'Failed to assign game to next player.'
|
return 'Failed to assign game to next player.'
|
||||||
|
|
|
@ -328,7 +328,7 @@ class Twitter(Module):
|
||||||
#tweets.reverse()
|
#tweets.reverse()
|
||||||
#for tweet in tweets:
|
#for tweet in tweets:
|
||||||
# tweet_text = self._return_tweet_or_retweet_text(tweet=tweet, print_source=True)
|
# 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
|
## friends timeline printed, find the latest id
|
||||||
#new_since_id = self._get_latest_tweet_id(tweets, since_id)
|
#new_since_id = self._get_latest_tweet_id(tweets, since_id)
|
||||||
|
@ -337,7 +337,7 @@ class Twitter(Module):
|
||||||
tweets.reverse()
|
tweets.reverse()
|
||||||
for tweet in tweets:
|
for tweet in tweets:
|
||||||
tweet_text = self._return_tweet_or_retweet_text(tweet=tweet, print_source=True)
|
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
|
# mentions printed, find the latest id
|
||||||
new_since_id = self._get_latest_tweet_id(tweets, new_since_id)
|
new_since_id = self._get_latest_tweet_id(tweets, new_since_id)
|
||||||
|
|
Loading…
Reference in New Issue