Skip to content

Commit a70fa41

Browse files
committed
Merge branch 'v1.1' into 'master'
Version 1.1 Flux RSS, groupes custom, réactions de levelup, commande de ban, etc. See merge request Altearn/gunibot/Gunibot.py!17
2 parents b2c3f60 + 28de9ba commit a70fa41

31 files changed

+2794
-419
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ config.json
88
.ssh/
99
.cache
1010
.bash*
11-
.profile
11+
.profile
12+
.idea/

args.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import discord
22
import re
33
from discord.ext import commands
4+
from utils import MyContext
45

56

67
class tempdelta(commands.Converter):
7-
async def convert(self, ctx: commands.Context, argument: str) -> int:
8+
async def convert(self, ctx: MyContext, argument: str) -> int:
89
d = 0
910
found = False
1011
for x in [('y', 86400*365), ('w', 604800), ('d', 86400), ('h', 3600), ('m', 60), ('min', 60)]:
@@ -22,7 +23,7 @@ async def convert(self, ctx: commands.Context, argument: str) -> int:
2223

2324

2425
class moderatorFlag(commands.Converter):
25-
async def convert(self, ctx: commands.Context, argument: str) -> str:
26+
async def convert(self, ctx: MyContext, argument: str) -> str:
2627
LogsFlags = ctx.bot.get_cog('ConfigCog').LogsFlags.FLAGS
2728
if argument not in LogsFlags.values():
2829
raise commands.errors.BadArgument(
@@ -34,7 +35,14 @@ def constant(word: str):
3435
class Constant(commands.Converter):
3536
w = word
3637

37-
async def convert(self, ctx: commands.Context, arg: str):
38+
async def convert(self, ctx: MyContext, arg: str):
3839
if arg != self.w:
3940
raise commands.errors.BadArgument('Unknown argument')
4041
return Constant
42+
43+
class arguments(commands.Converter):
44+
async def convert(self, ctx: MyContext, argument: str) -> dict:
45+
answer = dict()
46+
for result in re.finditer(r'(\w+) ?= ?\"((?:[^\"\\]|\\\"|\\)+)\"', argument):
47+
answer[result.group(1)] = result.group(2).replace('\\"', '"')
48+
return answer

checks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@ async def is_roles_manager(ctx: MyContext):
2121
r_manager = ctx.guild is None or ctx.author.guild_permissions.manage_roles or is_bot_admin(ctx)
2222
if not r_manager:
2323
raise CheckException('is_roles_manager')
24-
return True
24+
return True
25+
26+
async def can_group(ctx: MyContext):
27+
config = ctx.bot.server_configs[ctx.guild.id]
28+
if config["group_allowed_role"] is None:
29+
return True
30+
role = discord.utils.get(ctx.message.guild.roles, id=config["group_allowed_role"])
31+
if role in ctx.author.roles:
32+
return True

data/model.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,26 @@ CREATE TABLE IF NOT EXISTS `roles_levels` (
6767
PRIMARY KEY (guild, role)
6868
);
6969
CREATE INDEX IF NOT EXISTS idx_rolesrewards_guild ON `roles_levels` (`guild`);
70+
71+
CREATE TABLE IF NOT EXISTS `rss_flows` (
72+
`guild` BIGINT NOT NULL,
73+
`channel` BIGINT NOT NULL,
74+
`structure` VARCHAR(1000) NOT NULL,
75+
`type` VARCHAR(5) NOT NULL,
76+
`link` TEXT NOT NULL,
77+
`date` DATETIME,
78+
`roles` BLOB,
79+
`use_embed` BOOLEAN DEFAULT 0,
80+
`embed_structure` BLOB,
81+
`added_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
82+
);
83+
CREATE INDEX IF NOT EXISTS idx_rssflows_guild ON `rss_flows` (`guild`);
84+
85+
CREATE TABLE IF NOT EXISTS `groups` (
86+
`guild` BIGINT NOT NULL,
87+
`roleID` BIGINT NOT NULL,
88+
`ownerID` BIGINT NOT NULL,
89+
`channelID` BIGINT DEFAULT NULL,
90+
`privacy` BOOLEAN NOT NULL DEFAULT 0
91+
);
92+
CREATE INDEX IF NOT EXISTS idx_groups_guild ON `groups` (`guild`);

langs/en.yml

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ en:
4141
unknown-role: "Unable to find the role %{r} :confused:"
4242
unknown-server: Unknown server
4343
unknown-user: "Unable to find user %{u} :confused:"
44+
unknown-group: "Unable to find group %{u} :confused:"
4445
general:
4546
stats:
4647
title: "Bot statistics"
@@ -110,7 +111,49 @@ en:
110111
dep-notfound: Cannot find a role-link with this identifier. You can get the identifier of a link with the `%{p}rolelink list` command
111112
infinite: "Oops, it seems that this dependency can lead to an infinite loop with at least the following dependency: \"%{dep}\"\nIf you're sure you want to continue, enter 'yes' in the next %{t} seconds..."
112113
list: "List of your roles-links:"
113-
no-dep: You do not have any dependencies configured at the moment. Use the `%{p}rolelink create` command to add more dependencies
114+
no-dep: "You do not have any dependencies configured at the moment.\nUse the `%{p}rolelink create` command to add more dependencies"
115+
groups:
116+
list: "List of server groups:"
117+
created: "You have succefuly created the group %{name}"
118+
delete: "You have succefuly deleted the group %{name}"
119+
registred: "You have succefuly registred the group %{name}"
120+
unregistred: "You have succefuly unregistred the group %{name}"
121+
update_owner: "You have succefuly gived the group %{group} to ${owner}"
122+
update_name: "You have succefuly renamed the group %{group} to %{name}"
123+
update_privacy: "You have succefuly passed the group's privacy of %{group} to %{privacy}"
124+
join: "You have succefuly joined the group %{name}"
125+
leave: "You have succefuly leaved the group %{name}"
126+
joinbyforce: "You have succefuly forced %{user} to join %{name}"
127+
leavebyforce: "You have succefuly kicked %{user} of %{name}"
128+
give: "%{user}, %{owner} want to give you the group %{group}"
129+
channel_delete: "You have succefuly deleted the channel for the group %{group}"
130+
channel-create: "You have succefuly created the channel for the group %{name}"
131+
channel-registred: "You have succefuly registred the channel for the group %{name}"
132+
channel_unregister: "You have succefuly unregistred the channel for the group %{group}"
133+
userlist: "List of the members of the group"
134+
error:
135+
no-group: "You do not have any group created at the moment.\nUse the `%{p}group add` command to add groups"
136+
no-delete: "Cannot find a group with this identifier or name"
137+
no-unregistred: "Cannot find a group with this identifier or name"
138+
no-update: "Cannot find a group with this identifier or name. Check also if you are owner of this group or if you have the ADMINISTRATOR permission"
139+
exist: "A group with the name %{name} already exist"
140+
tomanygroup: "You own too many groups"
141+
not-owner: "You have to be owner of this group or ot have the ADMINISTRATOR permission"
142+
not-admin: "You have to have the ADMINISTRATOR permission"
143+
tomanygroupuser: "{user} got too many groups"
144+
timeout: "%{user} didn't reply so the owner update was canceled"
145+
badarg: "You have to provide \"public\" or \"private\""
146+
no-exist: "This group doesn't exist"
147+
private: "This group is private"
148+
already-in: "You're already in this group"
149+
not-in: "You're not in this group"
150+
owner: "You're owner of this group so you can't leave it"
151+
already-in-user: "This user is already in your group"
152+
not-in-user: "This user is not in your group"
153+
no-channel: "This group don't have a channel"
154+
no-delete-channel: "Cannot find a group with this identifier or name"
155+
channel-exist: "This group already have a channel"
156+
no-category: "You have to config a category for groups channels : `%{p}config group_channel_category`"
114157
hypesquad:
115158
no-role: You don't have any house roles configured!
116159
forbidden: Oops, an error occurred. Please check my permissions!
@@ -184,7 +227,7 @@ en:
184227
title: Role deleted
185228
desc: The role %{name} has just been deleted
186229
members: "Member count:"
187-
role_update:
230+
role_updated:
188231
title: Role updated
189232
desc: The role %{mention} (%{name}) has just been modified
190233
name: "Name:"
@@ -224,10 +267,37 @@ en:
224267
cookie:
225268
give: "Here is for you %{to}: :cookie:\nFrom %{giver}"
226269
self: "Here is for you %{to}: :cookie:"
270+
hoster:
271+
info: ":speech_balloon: Discord server: <https://discord.gg/RUPKTmC>\n:globe_with_meridians: Website: <https://clients.inovaperf.fr/aff.php?aff=514>\n:money_with_wings: 20% discount on the first purchase with the code `GUNIVERS`"
227272
flipacoin:
228273
heads: "Heads!"
229274
tails: "Tails!"
230275
side: "Side!"
276+
kills:
277+
"0": "{2}.exe *has stopped working*"
278+
"1": "Oh you, you gonna to die!"
279+
"2": "***BOUM!*** {1} fell into a trap posed by {0}!"
280+
"3": "Luckily, the ground has cushioned the fall of {1}!"
281+
"4": "{0} shouted \"Fus Roh Dah\" while {1} was next to a cliff..."
282+
"5": "No, you can't stop bullets with your hands {1} :shrug:"
283+
"6": "You have to be __in__ the elevator {1}, not __above__..."
284+
"7": "{1} stayed too close to the speakers during a heavy metal concert."
285+
"8": "Staying within 10 meters of an atomic explosion wasn't a good idea {1}..."
286+
"9": "No! Double jumps are not possible {1}!"
287+
"10": "{1} imitated Icare... splash."
288+
"11": "It's nice to have a portal gun {1}, but don't open portals above spades..."
289+
"12": "{1} died. Peace to their soul... :sneezing_face:"
290+
"13": "{0} killed {1}"
291+
"14": "{1} was shot by {0}"
292+
"15": "Bye {1}! :ghost:"
293+
"16": "{1} saw a flying anvil fall... on their head :head_bandage:"
294+
"17": "{1} commit suicide after {0} has cut their connection"
295+
"18": "Caution {1}! Fire burns :fire:"
296+
"19": "{1} fought zombies without shovel"
297+
"20": "{1} tried to hug a creeper"
298+
"21": "{1}, lava baths are hot, but lava burns..."
299+
"22": "{1} tried a rocket jump"
300+
"23": "You shouldn't listen to the pretty melody of the Lullaby, {1} :musical_note:"
231301
dataja: "https://zrunner.me/d-a-t-a/en.html"
232302
perms:
233303
list:
@@ -255,10 +325,12 @@ en:
255325
priority_speaker: Priority speaker
256326
read_message_history: Read message history
257327
read_messages: View channel
328+
request_to_speak: Request to speak
258329
send_messages: Send messages
259330
send_tts_messages: Send Text-to-Speech messages
260331
speak: Speak
261332
stream: Video
333+
use_slash_commands: Use slash commands
262334
use_voice_activation: Use voice activity
263335
view_audit_log: View audit log
264336
view_guild_insights: View server insights
@@ -301,6 +373,7 @@ en:
301373
VoiceChannels: Voice channels
302374
Welcome: Welcome
303375
XP: XP levels
376+
Groups: Groups
304377
thanks:
305378
add:
306379
done: "%{user} has received your thanks. They now have %{amount} active thanks!"
@@ -350,6 +423,61 @@ en:
350423
result:
351424
one: Deleted 1 channel
352425
many: Deleted %{count} channels
426+
rss:
427+
change-txt: "The current message contain \n```\n{text}\n```\nPlease enter the text to be used in a new post. You can use several variables, there is the list:\n- `{author}`: post author\n- `{channel}`: channel name (usually the same as the author)\n- `{date}`: post date (UTC)\n- `{link}` or `{url}`: a link to the post\n- `{logo}`: an emoji representing the type of post (web, Twitter, YouTube...)\n- `{mentions}`: list of mentionned roles\n- `{title}`: post title"
428+
choose-delete: "Chose a feed to delete"
429+
choose-mentions-1: "Chose a feed to edit"
430+
choose-roles: "Wich role do you want to mention?"
431+
delete-success: "The feed has been successfully deleted!"
432+
deviant: "DeviantArt"
433+
deviant-default-flow: "{logo} | New creation of {author}: **{title}**\nPublished on {date}\nLink: {link}\n{mentions}"
434+
deviant-form-last: "{logo} | There is the last creation of {author}:\n{title}\nPublished on {date}\nLink: {url}"
435+
embed-json-changed: "The feed's embed has been successfully edited"
436+
fail-add: "An error occurred while processing your response. Please try again later, or contact bot support (enter the command `about` for the server link)"
437+
flow-limit: "For performance reasons, you cannot track more than {} rss feeds per server."
438+
guild-complete: "{} rss feeds were correctly reloaded, in {} seconds!"
439+
guild-error: "An error occurred during the procedure: `{}`\nIf you think this error is not your fault, you can notify support"
440+
guild-loading: "Reloading {}"
441+
invalid-flow: "This url is invalid (empty rss feed or inaccessible) :confused:"
442+
invalid-link: "Oops, this url address is invalid or incomplete :confused:"
443+
list: "*Enter the number of the stream to be modified*\n\n**Link - Type - Channel - Roles**\n"
444+
list-title: "List of active feeds on the server {server}"
445+
list-result: "Type: {}\nChannel: {}\nLink/ID: {}\nMentionned roles: {}\nIdentifier: {}\nLast post: {}"
446+
list2: "*Enter the number of the feed to be deleted*\n\n**Link - Type - Channel**\n"
447+
mc: "Minecraft"
448+
move-success: "The rss feed n°{} has been moved to the channel {} !"
449+
no-feed: "Oops, you have no rss feed to manage!"
450+
no-feed2: "This server has no rss feeds!"
451+
no-roles: "No roles have been configured yet."
452+
not-a-role: "This role cannot be found. Try again."
453+
nothing: "I couldn't find anything on this search :confused:"
454+
research-timeout: "The web page took too long to respond, I had to abort the process :eyes:"
455+
roles-0: "This feed has been modified to mention roles {}"
456+
roles-1: "This feed has been modified to not mention any roles"
457+
roles-list: "Here is the list of roles already mentioned: {}"
458+
success-add: "The rss feed of type '{}' with the link <{}> has been added to the {} channel!"
459+
text-success: "The text of the feed n°{} has been modified! New text: \n```\n{}\n```"
460+
too-long: "You waited too long, sorry :hourglass:"
461+
tw: "Twitter"
462+
tw-default-flow: "{logo} | New tweet of {author}! ({date})\n\n{title}\n\nLink: {link}\n\n{mentions}"
463+
tw-form-last: "{logo} | Here is the latest tweet from {author}:\nWritten on {date}\n\n{title}\n\nLink: {url}\n"
464+
tw-help: "To search for a twitter channel, you have to enter the id of this channel. You will find it at the end of the url of the channel, it usually corresponds to the name of the user. For example, for *https://twitter.com/Gunivers_*, you have to enter `Gunivers_`"
465+
twitch: "Twitch"
466+
twitch-default-flow: "{logo} | {author} is live! ({date})\n\n{title}\n\nLink: {link}\n\n{mentions}"
467+
twitch-form-last: "{logo} | Here is the last video of {author}:\n{title}\nPublished on {date}\nLink: {url}\n"
468+
use_embed-same: "The use of embeds for this feed has not changed"
469+
use_embed-success: "The value has been changed to {v} for stream n°{f} !"
470+
use_embed_false: "This feed does not use embeds to be sent. Do you want to use embeds for this feed? (true/false)"
471+
use_embed_true: "This feed currently uses embeds to be sent. Do you still want to use embeds for this feed? (true/false)"
472+
web: "Web"
473+
web-default-flow: "{logo} | Now post on {author} ({date}) :\n {title}\n\n{link}\n\n{mentions}"
474+
web-form-last: "{logo} | Here is the last post of {author}:\n**{title}**\n*Written on {date}*\nLink: {link}"
475+
web-help: "To search for an rss feed from any website, just enter the url of the rss/atom feed as a parameter. If the feed is valid, I will return the last article posted on this site"
476+
web-invalid: "Oops, this url address is invalid :confused:"
477+
yt: "YouTube"
478+
yt-default-flow: "{logo} | New vidéo from {author}: **{title}**\nPublished on {date}\nLink: {link}\n{mentions}"
479+
yt-form-last: "{logo} | ere is the last video of {author}:\n{title}\nPublished on {date}\nLink: {url}"
480+
yt-help: "To search for a youtube channel, you need to enter the id of this channel. You will find it at the end of the url of the channel, it can be either the name or a random sequence of characters"
353481
xp:
354482
card:
355483
level: Level

0 commit comments

Comments
 (0)