Browse Source

add announce channel

master
dave 1 year ago
parent
commit
e2c412fdef
3 changed files with 30 additions and 9 deletions
  1. +15
    -1
      docs/api/modules/stockplay.rst
  2. +3
    -1
      examples/data/config/StockPlay.json
  3. +12
    -7
      pyircbot/modules/StockPlay.py

+ 15
- 1
docs/api/modules/stockplay.rst 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
---------------


+ 3
- 1
examples/data/config/StockPlay.json View File

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

+ 12
- 7
pyircbot/modules/StockPlay.py 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",
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))


Loading…
Cancel
Save