76 lines
3.0 KiB
Python
76 lines
3.0 KiB
Python
|
|
import configparser
|
||
|
|
import atexit
|
||
|
|
import discord
|
||
|
|
from pathlib import Path
|
||
|
|
#/home/pi/discord/jar-bot/
|
||
|
|
ini = Path('/home/pi/discord/jar-bot/count.ini')
|
||
|
|
if not ini.is_file():
|
||
|
|
f = open("count.ini", "x")
|
||
|
|
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
#coin_plus(message.author.display_name,message.content.count('\U0001FA99'))
|
||
|
|
def coin_plus(name,plus):
|
||
|
|
Config.read(ini)
|
||
|
|
if Config.has_section(name):
|
||
|
|
count = Config.getint(name,'count')
|
||
|
|
count = count + plus
|
||
|
|
Config.set(name,'count',str(count))
|
||
|
|
with open(ini, 'w') as configfile:
|
||
|
|
Config.write(configfile)
|
||
|
|
else:
|
||
|
|
Config.add_section(name)
|
||
|
|
count = plus
|
||
|
|
Config.set(name,'count',str(count))
|
||
|
|
with open(ini, 'w') as configfile:
|
||
|
|
Config.write(configfile)
|
||
|
|
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
#await stand_out(message.channel)
|
||
|
|
async def stand_out(chanel):
|
||
|
|
Config.read(ini)
|
||
|
|
stand = list()
|
||
|
|
await chanel.send('Der Stand ist:')
|
||
|
|
for x in Config.sections():
|
||
|
|
count = Config.getint(x,'count')
|
||
|
|
stand.append([count, x])
|
||
|
|
stand.sort(reverse=True)
|
||
|
|
for item in stand:
|
||
|
|
if item[0] == "1":
|
||
|
|
await chanel.send(item[1] + ' hat eine Münze in das Glas geworfen')
|
||
|
|
else:
|
||
|
|
await chanel.send(item[1] + ' hat '+ str(item[0]) +' Münzen in das Glas geworfen')
|
||
|
|
with open(ini, 'w') as configfile:
|
||
|
|
Config.write(configfile)
|
||
|
|
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
#\U0001FA99 - coin
|
||
|
|
#\U0001F4B8 - money with wings
|
||
|
|
#\U0001F4B0 - moneybag
|
||
|
|
client = discord.Client()
|
||
|
|
Config = configparser.ConfigParser()
|
||
|
|
@client.event
|
||
|
|
async def on_ready():
|
||
|
|
print('We have logged in as {0.user}'.format(client))
|
||
|
|
@client.event
|
||
|
|
async def on_message(message):
|
||
|
|
if message.author == client.user:
|
||
|
|
return
|
||
|
|
if message.channel.name == 'das-glas':
|
||
|
|
if message.content.count('\U0001FA99')>0:
|
||
|
|
if len(message.mentions)>0:
|
||
|
|
await message.add_reaction('\U0001F4B8')
|
||
|
|
for j in message.mentions:
|
||
|
|
coin_plus(j.display_name,message.content.count('\U0001FA99'))
|
||
|
|
else:
|
||
|
|
await message.add_reaction('\U0001F4B0')
|
||
|
|
coin_plus(message.author.display_name,message.content.count('\U0001FA99'))
|
||
|
|
elif message.content.startswith('!stand'):
|
||
|
|
await message.delete()
|
||
|
|
for x in message.author.roles:
|
||
|
|
if str(x) == "Meh":
|
||
|
|
await stand_out(message.channel)
|
||
|
|
else:
|
||
|
|
await message.delete()
|
||
|
|
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
client.run('ODE1Mzc0MDc0NDU5OTc5ODM2.YDreSA.q494wu3zvinCJ6QiffrWvoUVibc')
|
||
|
|
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
atexit.register(client.close)
|