Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from Gelbpunkt/v3.4-dev
Browse files Browse the repository at this point in the history
v3.4 dev
  • Loading branch information
Gelbpunkt authored Apr 1, 2019
2 parents c90b8f6 + 6b4cf48 commit 9ee9f1f
Show file tree
Hide file tree
Showing 207 changed files with 3,472 additions and 1,992 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Please note that IdleRPG is dual-licensed, more information in the README:
https://github.com/Gelbpunkt/IdleRPG/tree/v3.4-dev#license
Below is the brief text of the GNU Affero General Public License.

The IdleRPG Discord Bot
Copyright (C) 2018-2019 Diniboy and Gelbpunkt

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
651 changes: 651 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,29 @@ You may [submit an issue](https://github.com/Gelbpunkt/IdleRPG/issues) or open p

The master branch is always the *latest stable* version. For development versions, check other branches please.

It is currently published as "All rights reserved", but we are working on a better licensing to give users more freedoms.
## License

The IdleRPG Project is dual-licensed under the terms of the [GNU Affero General Public License 3.0](https://github.com/Gelbpunkt/IdleRPG/blob/master/LICENSE.md) ("AGPL") for non-commercial and the Travitia License for commercial use. A copy of the AGPL can be found in the [LICENSE.md](https://github.com/Gelbpunkt/IdleRPG/blob/master/LICENSE.md) file. The Travitia license can be obtained by sending a formal request to business [at] travitia \<dot\> xyz with usecase, name and address. "Commercial use" includes any kind of revenue made with or based upon the software, even donations.

The AGPL allows you to:
- [x] Modify the code
- [x] Distribute it

It however does not allow you to:
- [ ] Sublicense
- [ ] Hold liable

You must:
- Include the copyright
- Include the License
- Disclose the source
- State changes

Summary and information taken from [here](https://tldrlegal.com/license/gnu-affero-general-public-license-v3-(agpl-3.0)).

## Current goals

1. Work on a total rewrite for v3.4
2. Add all features from Travitia in v5
3. Multiprocess
4. Move vote handling from the Bot to our webserver
1. Prettify and fix v3.4 code

Todo in v3.4:

Expand All @@ -22,14 +37,11 @@ Todo in v3.4:
- Cleanup, remove unnecessary code, beautify
- Use custom converters instead of own handling every time
- Move battles to a backend function
- Clean up the directory structure
- Move pagination to a module
- Rewrite everything

## Can I selfhost?

The answer is simple: **No** (where is the fun at hosting a big MMO your own? Cool, you got everything, but where is the fun of the global community?)

You're allowed to selfhost for testing your own changes that you will submit with a pull request later.
[Yes, as long as you provide the code for everyone.](https://github.com/Gelbpunkt/IdleRPG/blob/master/LICENSE.md#13-remote-network-interaction-use-with-the-gnu-general-public-license)

## How do I test my changes?

Expand All @@ -38,15 +50,18 @@ Note: This requires you to have Redis and Postgres working, and, depending on wh
```
git clone https://github.com/Gelbpunkt/IdleRPG
cd IdleRPG
pip3 install -r requirements.txt
mv config.py.example config.py
(edit config.py to your needs now)
(now do your changes)
python3 idlerpg.py
(edit config.py.example to your database credentials)
./setup.sh
(do changes now)
systemctl start idlerpg
```

A systemd unit file has been bundled as `idlerpg.service`.

## Code style
## Contributing

IdleRPG uses [black](https://github.com/ambv/black) for code style. Please always run `test.sh` before submitting a pull request.

Make sure black is done and flake8 throws no issues, then you are ready to submit a PR.

IdleRPG uses [black](https://github.com/ambv/black) for code style. Please always run `black .` before submitting a pull request.
**Make sure you sign the CLA [here](https://cla-assistant.io/Gelbpunkt/IdleRPG), else we cannot merge your changes.**
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
9 changes: 0 additions & 9 deletions chess/COPYING

This file was deleted.

3 changes: 0 additions & 3 deletions chess/README.md

This file was deleted.

Binary file removed chess/bb.png
Diff not rendered.
Binary file removed chess/bk.png
Diff not rendered.
Binary file removed chess/bn.png
Diff not rendered.
Binary file removed chess/bp.png
Diff not rendered.
Binary file removed chess/bq.png
Diff not rendered.
Binary file removed chess/br.png
Diff not rendered.
Binary file removed chess/tile_d.png
Diff not rendered.
Binary file removed chess/tile_l.png
Diff not rendered.
Binary file removed chess/wb.png
Diff not rendered.
Binary file removed chess/wk.png
Diff not rendered.
Binary file removed chess/wn.png
Diff not rendered.
Binary file removed chess/wp.png
Diff not rendered.
Binary file removed chess/wq.png
Diff not rendered.
Binary file removed chess/wr.png
Diff not rendered.
69 changes: 69 additions & 0 deletions classes/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
The IdleRPG Discord Bot
Copyright (C) 2018-2019 Diniboy and Gelbpunkt
This software is dual-licensed under the GNU Affero General Public License for non-commercial and the Travitia License for commercial use.
For more information, see README.md and LICENSE.md.
"""


import discord
import datetime

from discord.ext import commands


class Bot(commands.AutoShardedBot):
def __init__(self, **kwargs):
super().__init__(**kwargs)

self.launch_time = (
datetime.datetime.now()
) # we assume the bot is created for use right now

self.mention_formatter = commands.clean_content()

@property
def disp(self):
return self.author.display_name

@property
def uptime(self):
return datetime.datetime.now() - self.launch_time

async def get_user_global(self, user_id: int):
user = self.get_user(user_id)
if user:
return user
data = await self.cogs["Sharding"].handler("get_user", 1, {"user_id": user_id})
if not data:
return None
data = data[0]
data["username"] = data["name"]
user = discord.User(state=self._connection, data=data)
self.users.append(user)
return user

async def reset_cooldown(self, ctx):
await self.redis.execute(
"DEL", f"cd:{ctx.author.id}:{ctx.command.qualified_name}"
)

async def send_message(
self,
target,
content=None,
*,
escape_mass_mentions=True,
escape_mentions=False,
**fields,
):
if escape_mass_mentions:
content = content.replace("@here", "@\u200bhere").replace(
"@everyone", "@\u200beveryone"
)
if escape_mentions:
# content = await self.mention_formatter.convert(self, content)
pass

await super(Bot, self).send_message(target, content=content, **fields)
27 changes: 27 additions & 0 deletions classes/converters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
The IdleRPG Discord Bot
Copyright (C) 2018-2019 Diniboy and Gelbpunkt
This software is dual-licensed under the GNU Affero General Public
License for non-commercial and the Travitia License for commercial
use.
For more information, see README.md and LICENSE.md.
"""

import discord

from discord.ext import commands


class User(commands.Converter):
async def convert(self, ctx, argument):
# TODO: Try the local users first
data = await ctx.bot.cogs["Sharding"].handler(
"fetch_user", 1, {"user_inp": argument}
)
if not data:
raise commands.BadArgument(ctx.message, argument)
data = data[0]
data["username"] = data["name"]
user = discord.User(state=ctx.bot._connection, data=data)
ctx.bot.users.append(user)
return user
31 changes: 21 additions & 10 deletions cogs/admin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import discord
"""
The IdleRPG Discord Bot
Copyright (C) 2018-2019 Diniboy and Gelbpunkt
This software is dual-licensed under the GNU Affero General Public License for non-commercial and the Travitia License for commercial use.
For more information, see README.md and LICENSE.md.
"""


import asyncio

from discord.ext import commands
from utils.checks import *
from utils.checks import is_admin, user_has_char
from classes.converters import User


class Admin:
class Admin(commands.Cog):
def __init__(self, bot):
self.bot = bot

@is_admin()
@commands.command(aliases=["agive"], description="Gift money!", hidden=True)
async def admingive(self, ctx, money: int, other: discord.User):
async def admingive(self, ctx, money: int, other: User):
if not await user_has_char(self.bot, other.id):
return await ctx.send("That person hasn't got a character.")
async with self.bot.pool.acquire() as conn:
Expand All @@ -24,7 +35,7 @@ async def admingive(self, ctx, money: int, other: discord.User):

@is_admin()
@commands.command(aliases=["aremove"], description="Delete money!", hidden=True)
async def adminremove(self, ctx, money: int, other: discord.User):
async def adminremove(self, ctx, money: int, other: User):
if not await user_has_char(self.bot, other.id):
return await ctx.send("That person hasn't got a character.")
async with self.bot.pool.acquire() as conn:
Expand All @@ -39,7 +50,7 @@ async def adminremove(self, ctx, money: int, other: discord.User):
@commands.command(
aliases=["adelete"], description="Deletes a character.", hidden=True
)
async def admindelete(self, ctx, other: discord.User):
async def admindelete(self, ctx, other: User):
if other.id in ctx.bot.config.admins:
return await ctx.send("Very funny...")
if not await user_has_char(self.bot, other.id):
Expand All @@ -52,7 +63,7 @@ async def admindelete(self, ctx, other: discord.User):

@is_admin()
@commands.command(aliases=["arename"], description="Changes a character name")
async def adminrename(self, ctx, target: discord.User):
async def adminrename(self, ctx, target: User):
if target.id in ctx.bot.config.admins:
return await ctx.send("Very funny...")
if not await user_has_char(self.bot, target.id):
Expand All @@ -70,7 +81,7 @@ def mycheck(amsg):

try:
name = await self.bot.wait_for("message", timeout=60, check=mycheck)
except:
except asyncio.TimeoutError:
return await ctx.send("Timeout expired.")
name = name.content
async with self.bot.pool.acquire() as conn:
Expand All @@ -82,7 +93,7 @@ def mycheck(amsg):

@is_admin()
@commands.command(aliases=["acrate"], description="Gives crates to a user.")
async def admincrate(self, ctx, target: discord.Member, amount: int = 1):
async def admincrate(self, ctx, target: User, amount: int = 1):
async with self.bot.pool.acquire() as conn:
await conn.execute(
'UPDATE profile SET "crates"="crates"+$1 WHERE "user"=$2;',
Expand All @@ -97,7 +108,7 @@ async def admincrate(self, ctx, target: discord.Member, amount: int = 1):

@is_admin()
@commands.command(aliases=["axp"], description="Gives XP to a user.")
async def adminxp(self, ctx, target: discord.Member, amount: int):
async def adminxp(self, ctx, target: User, amount: int):
async with self.bot.pool.acquire() as conn:
await conn.execute(
'UPDATE profile SET "xp"="xp"+$1 WHERE "user"=$2;', amount, target.id
Expand Down
Loading

0 comments on commit 9ee9f1f

Please sign in to comment.