Compare commits

...

5 Commits

Author SHA1 Message Date
jmjl e7bb648f96 Almost all options being config options
The options in the bot configuration should be taken from the
config.json not from the bot source file, as hardcoding options is bad
I've also refactorized the handler, and made most options be config
options
2023-09-01 14:12:35 +00:00
jmjl ad4b711a7c run.sh be able to enable the test mode
This commit sends the first parameter of run.sh into bot.py, such that
the test mode can be used with run.
2023-09-01 14:06:48 +00:00
jmjl 37812b90f7 Ignore data directories and existing files only
This commit modfies the gitignore in such a way to ignore the data
directory, and supposes in the future a new data directory for users,
named 'users' will be created.

This commit furthermore removes gitignores for certain files that don't
exist in this git repository but existed in the repository this
repository's been based of.
2023-09-01 12:13:46 +00:00
jmjl e6054e713d Delete undofiles
I preffer moving them to another directory and not having them take up
space on the repo.
2023-09-01 12:07:53 +00:00
jmjl 9471383f97 tilde: Also show percentage on brainwash
Requested by login
2023-06-26 15:49:40 +00:00
13 changed files with 18 additions and 29 deletions

17
.gitignore vendored
View File

@ -1,14 +1,7 @@
venv/ *.log
__pycache__/
config.json
data/
json/ json/
users/ users/
__pycache__/ venv/
doctorow_ebooks.txt
.indexme
*.swp
*.log
config.ini
config.json
plugins/pronouns.json
plugins/ebooks/
optout
secrets.toml

22
bot.py
View File

@ -8,28 +8,22 @@ with open('config.json') as c:
config = json.load(c) config = json.load(c)
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1: if len(sys.argv) > 1 and if sys.argv[1] == '--test-mode':
if sys.argv[1] == '--test-mode': channels = config['test']['channels']
channels = ['#jmjl-devel'] cmd_prefix = config['test']['cmd_prefix']
nick = 'ju[dev]' nick = f"{config['nickname']}{config['test']['nick_suffix']}"
prefix_plugins = True prefix_plugins = True
cmd_prefix='^'
else: else:
channels = config['channels'] channels = config['channels']
cmd_prefix = config['cmd_prefix']
nick = config['nickname']
prefix_plugins = False prefix_plugins = False
cmd_prefix='&'
nick = 'ju'
else:
channels = config['channels']
nick = 'ju'
prefix_plugins = False
cmd_prefix='&'
bot = pinhook.bot.Bot( bot = pinhook.bot.Bot(
channels, channels,
nick, nick,
'localhost', 'localhost',
ops=['jmjl'], ops=config['ops'],
ns_pass='ju {}'.format(config['password']), ns_pass=f"{config['nickname'] {config['password']}",
#ns_pass=config['password'], #ns_pass=config['password'],
nickserv='nickserv', nickserv='nickserv',
cmd_prefix=cmd_prefix, cmd_prefix=cmd_prefix,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -111,6 +111,8 @@ def cleanwash_money(msg):
#new_balance=((__import__('random').randint(80,110)/100)*balance).split('.')[0] #new_balance=((__import__('random').randint(80,110)/100)*balance).split('.')[0]
new_balance = Decimal(randint(80,110))/Decimal(100)*Decimal(balance) new_balance = Decimal(randint(80,110))/Decimal(100)*Decimal(balance)
new_balance = new_balance.quantize(Decimal('1.'), rounding=ROUND_DOWN) new_balance = new_balance.quantize(Decimal('1.'), rounding=ROUND_DOWN)
percentage_return = new_balance/balance * Decimal(100)
percentage_return = percentage_return.quantize(Decimal('.00'), rounding=ROUND_DOWN)
#jackpot_balance=(0.10*balance).split('.')[0] #jackpot_balance=(0.10*balance).split('.')[0]
jackpot_balance = (Decimal(0.10)*Decimal(balance)).quantize(Decimal('1.'), rounding=ROUND_DOWN) jackpot_balance = (Decimal(0.10)*Decimal(balance)).quantize(Decimal('1.'), rounding=ROUND_DOWN)
with open(util.tilde.JACKPOT_FILE, "r+") as jackpotfile: with open(util.tilde.JACKPOT_FILE, "r+") as jackpotfile:
@ -119,6 +121,6 @@ def cleanwash_money(msg):
jackpotfile.truncate() jackpotfile.truncate()
jackpot_now = str(jackpot + jackpot_balance) jackpot_now = str(jackpot + jackpot_balance)
jackpotfile.write(jackpot_now) jackpotfile.write(jackpot_now)
message = f"Cleanwashed {balance}TCN, and given the user {new_balance}TCN and contributed {jackpot_balance}TCN to the balance, jackpot at {jackpot_now}TCN" message = f"Cleanwashed {balance}TCN, and given the user {new_balance}TCN ({percentage_return}%) and contributed {jackpot_balance}TCN to the balance, jackpot at {jackpot_now}TCN"
util.tilde.admin_update_tilde(nick,amount=new_balance,time=msg.timestamp,comment=message) util.tilde.admin_update_tilde(nick,amount=new_balance,time=msg.timestamp,comment=message)
return pinhook.plugin.message(message) return pinhook.plugin.message(message)

2
run.sh
View File

@ -2,4 +2,4 @@
cd ~jmjl/dev/juju cd ~jmjl/dev/juju
exec /home/jmjl/usr/share/python/venv/pinhook-juju/bin/python /home/jmjl/dev/juju/bot.py exec /home/jmjl/usr/share/python/venv/pinhook-juju/bin/python /home/jmjl/dev/juju/bot.py "$1"