add announce channel

This commit is contained in:
dave 2019-10-06 09:39:18 -07:00
parent 4161be93e4
commit e2c412fdef
3 changed files with 30 additions and 9 deletions

View File

@ -55,7 +55,9 @@ Config
"tcachesecs": 300,
"rcachesecs": 14400,
"bginterval": 300,
"midnight_offset": 0
"midnight_offset": 0,
"announce_trades": false,
"announce_channel": "#trades"
}
.. cmdoption:: startbalance
@ -106,6 +108,18 @@ Config
Default: 0
.. cmdoption:: announce_trades
Boolean option to announce all trades in a specific channel.
Default: false
.. cmdoption:: announce_channel
Channel name to announce all trades in.
Default: not set
Class Reference
---------------

View File

@ -5,5 +5,7 @@
"tcachesecs": 300,
"rcachesecs": 14400,
"bginterval": 300,
"midnight_offset": 0
"midnight_offset": 0,
"announce_trades": true,
"announce_channel": "#trades"
}

View File

@ -309,13 +309,18 @@ class StockPlay(ModuleBase):
self.set_bal(DUSTACCT, dustbal + int(dust * 100))
# notify user
self.bot.act_PRIVMSG(trade.replyto,
"{}: {} {} {} for {}. cash: {}".format(trade.nick,
"bought" if trade.buy else "sold",
message = "{} {} {} for {}. cash: {}".format("bought" if trade.buy else "sold",
trade.amount,
trade.symbol,
format_price(trade_price),
format_price(nickbal)))
format_price(nickbal))
self.bot.act_PRIVMSG(trade.replyto, "{}: {}".format(trade.nick, message))
# announce message
if self.config.get("announce_trades"):
channel = self.config.get("announce_channel")
if channel:
self.bot.act_PRIVMSG(channel, "{}_ {}".format(trade.nick, message), priority=10)
self.log_trade(trade.nick, time(), "buy" if trade.buy else "sell",
trade.symbol, trade.amount, trade_price, str(symprice))