diff --git a/docs/api/modules/stockplay.rst b/docs/api/modules/stockplay.rst index 8a81e2b..e2a7a3d 100644 --- a/docs/api/modules/stockplay.rst +++ b/docs/api/modules/stockplay.rst @@ -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 --------------- diff --git a/examples/data/config/StockPlay.json b/examples/data/config/StockPlay.json index 8c87211..1a9459a 100644 --- a/examples/data/config/StockPlay.json +++ b/examples/data/config/StockPlay.json @@ -5,5 +5,7 @@ "tcachesecs": 300, "rcachesecs": 14400, "bginterval": 300, - "midnight_offset": 0 + "midnight_offset": 0, + "announce_trades": true, + "announce_channel": "#trades" } diff --git a/pyircbot/modules/StockPlay.py b/pyircbot/modules/StockPlay.py index 2abe226..1db065d 100644 --- a/pyircbot/modules/StockPlay.py +++ b/pyircbot/modules/StockPlay.py @@ -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", - trade.amount, - trade.symbol, - format_price(trade_price), - format_price(nickbal))) + message = "{} {} {} for {}. cash: {}".format("bought" if trade.buy else "sold", + trade.amount, + trade.symbol, + format_price(trade_price), + 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))