Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jonas747/yagpdb
Browse files Browse the repository at this point in the history
  • Loading branch information
jogramming committed Oct 23, 2019
2 parents 92b843c + e3f7df7 commit f4d2a12
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Just some shit
# Just some stuff
cmd/yagpdb/static/bower_components
cmd/yagpdb/static/pages
cmd/yagpdb/static/index.html
Expand All @@ -14,6 +14,6 @@ cmd/yagpdb/safebrowsing_db
cmd/yagpdb/static/video/*

# We don't want filthy pre-configured config files here ! >:O
# THe graw agent file
# The graw agent file
*.agent
*.exe
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Are you planning on contributing or suggesting something for the bot? Go ahead, just make sure you know what you are doing, we don't wanna mess with trying to fix the bot if someone breaks it!
Are you planning on contributing or suggesting something for the bot? Go ahead, just make sure you know what you are doing, we don't want to have to fix the bot if someone breaks it!

In order to make a suggestion, head to the [issues page](https://github.com/jonas747/yagpdb/issues) and make an issue titled "Suggestion: (name)" and fill out a little description. Please please please, check that this hasn't already been suggested or requested as a PR.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ I may update the bot at any point to require newer versions of any of these, so

**Steps for building:**

YAGPDB currently uses a lot of alternative branches of my projects, mainly because I also use a discordgo fork with a lot of goodies in it (why not push my changes upstream? Cause a shit ton of breaking changes that would never get accepted)
YAGPDB currently uses a lot of alternative branches of my projects, mainly because I also use a discordgo fork with a lot of goodies in it (why not push my changes upstream? Cause a ton of breaking changes that would never get accepted)

I'm working towards making YAGPDB fully `go get ...`-able

Expand Down
6 changes: 3 additions & 3 deletions automod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ This is version 2 of YAGPDB automoderator, v1 was scrapped and is deprecated, th
Quick design brainstorm:
- Servers can create several rulesets
- Rulesets contains sets of rules
- Rules contains a set of conditions that all needs to be met and another set of effects that will be executed once all the conditions for the rule is met
- Rules contains a set of conditions that all need to be met and another set of effects that will be executed once all the conditions for the rule are met
- Infringement counters can either be ruleset scoped, global scoped, or custom key scoped (also either ruleset or global scoped, per user or per channel etc as well maybe?)
- With this you could have a stricter set of automod rules for new users and and more soft one for "trusted" long time members
- You should be able to toggle rulesets on with commands, so if you need to slow down a channel or a raid is happening you can employ very strict automod rules via a single command invocation
- With this you could have a stricter set of automod rules for new users, and and more soft one for "trusted" long time members
- You should be able to toggle rulesets on with commands, so if you need to slow down a channel or a raid is in progress, you can employ very strict automod rules via a single command invocation

**Basic structure, with some example effects and conditions**

Expand Down
2 changes: 1 addition & 1 deletion automod/assets/automod.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h4>Create a new rule</h4>
<div class="col-lg-12">
<form action="/manage/{{.ActiveGuild.ID}}/automod/new_ruleset" method="post" data-async-form>
<h4>Create a new ruleset</h4>
<p class="help-block">Rulesets contains rules that you define afterwards</p>
<p class="help-block">Rulesets contain rules that you define afterwards</p>
<div class="form-group">
<label for="am-new-ruleset-name">Name</label>
<input type="text" name="Name" id="am-new-ruleset-name" class="form-control">
Expand Down
2 changes: 1 addition & 1 deletion automod/effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func (gf *GiveRoleEffect) Apply(ctxData *TriggeredRuleData, settings interface{}
err := common.AddRoleDS(ctxData.MS, settingsCast.Role)
if err != nil {
if code, _ := common.DiscordError(err); code != 0 {
return nil // discord responded with a proper error, we know that shit didn't happen
return nil // discord responded with a proper error, we know that it didn't break
}

// discord was not the cause of the error, in some cases even if the gateway times out the action is performed so just in case, scehdule the role removal
Expand Down
10 changes: 5 additions & 5 deletions bot/eventsystem/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# YAGPDBs event system
# YAGPDB's Event System

Instead of just using discordgo's standard simple event system, i like to experiment a little as i work on stuff to see what happens
Instead of just using discordgo's standard simple event system, I like to experiment a little as I work on stuff to see what happens.

It all boils down to a simple 3d slice of handlers (handlers [][][]Handler)
It all boils down to a simple 3D slice of handlers (handlers [][][]Handler)

The first index is the event index, that length is generated by events_gen.go
The first index is the event index, that length is generated by events_gen.go

Next index is order, there is 3 orders:

0 - first ran
1 - state handler is here
2 - last, ran concurrently from here on

orders 1 and 0 is ran syncrhounsly, but 2 is ran concurrently, this is to have the state be as proper as possible.
Orders 1 and 0 are run synchronously, but 2 is run concurrently, this is in order to have the state be as proper as possible.
2 changes: 1 addition & 1 deletion cmd/yagpdb/posts/20-log-0.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- Added ability to blacklist creation of logs from certain channels
- Added sharding, since were (somehow) nearing the 2.5k single shard limit.
- Started first steps to transitioning towards another state tracker that might give more consistent results when you're interacting with the bot
- Scheduled events now execute every 10 seconds (as opposed to 60) (means more responsive reminders and unmutes and shit)
- Scheduled events now execute every 10 seconds (as opposed to 60) (means more responsive reminders and unmutes, etc)
- Fixed reminders command displayed stuff like 1 hour and 59 minutes, the actual time was correct but it just showed the time wrong
- Added the ability for people with manage messages to view deleted messages, aswell as everyone (they are toggles)
- Made things more reponsive in general to changes, in the past when giving someone a role that gives them acces to the control panel it could take up to a minute before that takes effect, now thats instant, although changing permissions on existing roles wont kick fully in within 10 seconds still (not sure if i want to disable caching completely on this part or not)
16 changes: 8 additions & 8 deletions cmd/yagpdb/sampleenvfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ YAGPDB_CLIENTSECRET="Insert client secret here"
YAGPDB_BOTTOKEN="Bot token_here"

# Used for the website, required for https and csrf protection
YAGPDB_HOST="somehost.com"
YAGPDB_EMAIL="insert@email.here"
YAGPDB_HOST="somehost.com"
YAGPDB_EMAIL="insert@email.here"

# Postgres and redis
YAGPDB_PQHOST="localhost"
Expand Down Expand Up @@ -51,7 +51,7 @@ YAGPDB_TESTING=""
# Administration
# Used for YAGPDB_ADMINROLE and readonlyaccesrole
YAGPDB_MAIN_SERVER=""
# Admins have access to things like shard reconnects, and full access to admin only commands
# Admins have access to things like shard reconnects, and full access to admin only commands
YAGPDB_ADMIN_ROLE=""
# Users in the main server with this role can access the control panel page of any server, but they can't modify any settings
YAGPDB_READONLY_ACCESS_ROLE=""
Expand All @@ -63,7 +63,7 @@ YAGPDB_CONNSTATUS_CHANNEL=""

# Bot leaves joins to this channel
YAGPDB_BOTLEAVESJOINS=""

# Set to anything to disable the request logging of the webserver
YAGPDB_DISABLE_REQUEST_LOGGING=""

Expand All @@ -85,8 +85,8 @@ YAGPDB_GOOGLE_RECAPTCHA_SITE_KEY=""
YAGPDB_GOOGLE_RECAPTCHA_SECRET=""

# This will be used as the pubsubhubbub (websub) verify token when receiving callbacks on new video uploads
# if this gets leaked, people could spam shit
YAGPDB_YOUTUBE_VERIFY_TOKEN="some_secret_shit"
# if this gets leaked, people could spam stuff
YAGPDB_YOUTUBE_VERIFY_TOKEN="token_goes_here"

## These variables are for displaying an ad in the sidebar
# Leave empty for nothing
Expand All @@ -106,7 +106,7 @@ YAGPDB_GA_ID=""

# The feed on /managed
YAGPDB_ANNOUNCEMENTS_CHANNEL=""

# Datadog integration
YAGPDB_DOGSTATSDADDRESS="127.0.0.1:8125"

Expand All @@ -125,4 +125,4 @@ YAGPDB_GOOGLE_RECAPTCHA_SECRET=""
# YAGPDB_TWITTER_ACCESS_TOKEN=
# YAGPDB_TWITTER_ACCESS_TOKEN_SECRET=
# YAGPDB_TWITTER_CONSUMER_KEY=
# YAGPDB_TWITTER_CONSUMER_SECRET=
# YAGPDB_TWITTER_CONSUMER_SECRET=
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ exports.arrayBuffer2Blob = function(buffer, mimeType) {
}
catch (e) {

// well, fuck ?!
// it did an oopsie
throw new Error("Bug : can't construct the Blob.");
}
}
Expand Down Expand Up @@ -5727,7 +5727,7 @@ function GZheader() {
// but leave for few code modifications

//
// Setup limits is not necessary because in js we should not preallocate memory
// Setup limits is not necessary because in js we should not preallocate memory
// for inflate use constant limit in 65536 bytes
//

Expand Down Expand Up @@ -9152,4 +9152,4 @@ function ZStream() {
module.exports = ZStream;
},{}]},{},[9])
(9)
});
});
4 changes: 2 additions & 2 deletions commands/commands.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package commands

//go:generate sqlboiler --no-hooks psql
//REMOVED: generate easyjson commands.go
//REMOVED: generate easyjson commands.go

import (
"github.com/jonas747/dcmd"
Expand Down Expand Up @@ -70,7 +70,7 @@ func InitCommands() {
Prefix: &Plugin{},
}

// We have our own middleware before the argument parsing, this is to check for things such as wether the command is enabled at all
// We have our own middleware before the argument parsing, this is to check for things such as whether or not the command is enabled at all
CommandSystem.Root.AddMidlewares(YAGCommandMiddleware, dcmd.ArgParserMW)
CommandSystem.Root.AddCommand(cmdHelp, cmdHelp.GetTrigger())
CommandSystem.Root.AddCommand(cmdPrefix, cmdPrefix.GetTrigger())
Expand Down
2 changes: 1 addition & 1 deletion commands/tmplexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func execCmd(tmplCtx *templates.Context, dryRun bool, m *discordgo.MessageCreate

for i := range data.ContainerChain {
if i == len(data.ContainerChain)-1 {
// skip middlewares in original container to bypass cooldowns and shit
// skip middlewares in original container to bypass cooldowns and stuff
continue
}
runFunc = data.ContainerChain[len(data.ContainerChain)-1-i].BuildMiddlewareChain(runFunc, foundCmd)
Expand Down
2 changes: 1 addition & 1 deletion commands/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func CommonContainerNotFoundHandler(container *dcmd.Container, fixedMessage stri

enabled := false

// make sure that atleast 1 command in the container is enabled
// make sure that at least 1 command in the container is enabled
for _, v := range container.Commands {
cast := v.Command.(*YAGCommand)
settings, err := cast.GetSettingsWithLoadedOverrides(chain, data.GS.ID, channelOverrides)
Expand Down
8 changes: 4 additions & 4 deletions logs/plugin_bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var cmdWhois = &commands.YAGCommand{
}

if joinedAtDurStr == "" {
joinedAtDurStr = "Lesss than an hour ago"
joinedAtDurStr = "Less than an hour ago"
}

t := bot.SnowflakeToTime(member.ID)
Expand All @@ -123,7 +123,7 @@ var cmdWhois = &commands.YAGCommand{
Inline: true,
},
&discordgo.MessageEmbedField{
Name: "Account created",
Name: "Account Created",
Value: t.UTC().Format(time.RFC822),
Inline: true,
},
Expand All @@ -133,11 +133,11 @@ var cmdWhois = &commands.YAGCommand{
Inline: true,
},
&discordgo.MessageEmbedField{
Name: "Joined server at",
Name: "Joined Server At",
Value: joinedAtStr,
Inline: true,
}, &discordgo.MessageEmbedField{
Name: "Join server Age",
Name: "Join Server Age",
Value: joinedAtDurStr,
Inline: true,
},
Expand Down
6 changes: 3 additions & 3 deletions reddit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

### How the feed works

Uses the same method mee6 uses for reliable cost effective scanning of all reddit posts.
Uses the same method MEE6 uses for reliable cost effective scanning of all reddit posts.

works by by manually checking 100 ids per couple of second via the `/api/info.json?id=t3_id1,t3_id2` etc route.
Works by by manually checking 100 ids per couple of seconds via the `/api/info.json?id=t3_id1,t3_id2` etc route.

It then updates the cursor to the highest returned post id, continuing from that next call.

I don't believe this method has any bad parts at this moment, it seems to be more than enough even at a 5 second interval, unlike the polling of /all/new this does not appear to have any limitations on old posts and also shows absolutely all posts.
I don't believe this method has any faults at this moment, it seems to be more than enough even at a 5 second interval, unlike the polling of /all/new this does not appear to have any limitations on old posts and also shows absolutely all posts.

### Redis layout:

Expand Down
4 changes: 1 addition & 3 deletions stdcommands/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ var Command = &commands.YAGCommand{
info := fmt.Sprintf(`**YAGPDB - Yet Another General Purpose Discord Bot**
This bot focuses on being configurable and therefore is one of the more advanced bots.
It can perform a range of general purpose functionality (Reddit feeds, various commands, moderation utilities, automoderator functionality and so on) and it's configured through a web control panel.
I'm currently being run and developed by Jonas747#0001 (105487308693757952) but the bot is open source (<https://github.com/jonas747/yagpdb>), so if you know Go and want to make some contributions, DM me.
I'm currently being run and developed by Jonas747#0001 (105487308693757952) but the bot is open source (<https://github.com/jonas747/yagpdb>), so if you know Go and want to make some contributions, feel free to make a PR.
Control panel: <https://%s/manage>
Note: this bot has a lot of rough edges so to speak.
`, common.ConfHost.GetString())

return info, nil
Expand Down
4 changes: 2 additions & 2 deletions stdcommands/yagstatus/yagstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func cmdFuncYagStatus(data *dcmd.Data) (interface{}, error) {
Title: "YAGPDB Status, version " + common.VERSION,
Fields: []*discordgo.MessageEmbedField{
&discordgo.MessageEmbedField{Name: "Servers", Value: fmt.Sprint(servers), Inline: true},
&discordgo.MessageEmbedField{Name: "Go version", Value: runtime.Version(), Inline: true},
&discordgo.MessageEmbedField{Name: "Go Version", Value: runtime.Version(), Inline: true},
&discordgo.MessageEmbedField{Name: "Uptime", Value: common.HumanizeDuration(common.DurationPrecisionSeconds, uptime), Inline: true},
&discordgo.MessageEmbedField{Name: "Goroutines", Value: fmt.Sprint(numGoroutines), Inline: true},
&discordgo.MessageEmbedField{Name: "GC Pause Fraction", Value: fmt.Sprintf("%.3f%%", memStats.GCCPUFraction*100), Inline: true},
&discordgo.MessageEmbedField{Name: "Process Mem (alloc, sys, freed)", Value: fmt.Sprintf("%.1fMB, %.1fMB, %.1fMB", float64(memStats.Alloc)/1000000, float64(memStats.Sys)/1000000, (float64(memStats.TotalAlloc)/1000000)-allocated), Inline: true},
&discordgo.MessageEmbedField{Name: "System Mem (used, total)", Value: sysMemStats, Inline: true},
&discordgo.MessageEmbedField{Name: "System load (1, 5, 15)", Value: sysLoadStats, Inline: true},
&discordgo.MessageEmbedField{Name: "System Load (1, 5, 15)", Value: sysLoadStats, Inline: true},
},
}

Expand Down
12 changes: 6 additions & 6 deletions tickets/assets/tickets_control_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ <h2 class="card-title">Tickets enabled</h2>
<div class="card-body">
<div class="row">
<div class="col">
<p>Tickets is a plugin which gives the ability for users on your server to open tickets which then only your staff and other ticket participants can interact with.</p>
<p>Tickets is a plugin which gives the ability for users on your server to open tickets, which then only your staff and other ticket participants can interact with.</p>
<p>The flow goes like this:</p>
<ol>
<li>User opens a ticket using <code>-ticket open (reason-here)</code></li>
<li>A new channel gets made in the open tickets category</li>
<li>Permissions on that channel is set so that only ticket participants gets access</li>
<li>Permissions on that channel is set so that only ticket participants get access</li>
<li>User can also add more people to the ticket</li>
<li>User talks with the staff, posts evidence in attachments or links</li>
<li>When its over the ticket is closed</li>
<li>When it's over, the ticket is closed</li>
<li>All attachments and message history will then be downloaded and put in another channel (specified below)</li>
<li>Channel gets deleted</li>
</ol>
<p>There's more functionality here thats not mentioned, use <code>-help ticket</code> for all the commands.<br>
<p>There's more functionality here that's not mentioned, use <code>-help ticket</code> for all the commands.<br>
More functionality is also planned, such as adding a interface on the website so that it can be used for things like ban appeals.</p>
</div>
</div>
Expand All @@ -50,7 +50,7 @@ <h2 class="card-title">Tickets enabled</h2>
</select>
</div>
<div class="form-group">
<label>Role(s) for people considered mods (tickets can be set to a admin only mode)</label><br>
<label>Role(s) for people considered mods (tickets can be set to an admin only mode)</label><br>
<select name="ModRoles" class="multiselect form-control" multiple="multiple" data-plugin-multiselect>
{{roleOptionsMulti .ActiveGuild.Roles nil .PluginSettings.ModRoles}}
</select>
Expand Down Expand Up @@ -116,4 +116,4 @@ <h2 class="card-title">Tickets enabled</h2>

{{template "cp_footer" .}}

{{end}}
{{end}}
4 changes: 2 additions & 2 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

This is the core webserver for YAGPDB, it handles general stuff like authentication.

Currently it only uses 2 HTTP methods, that is GET for everything that does not change state, and POST for everything else.
Currently it only uses 2 HTTP methods: GET for everything that does not change state, and POST for everything else.

The web package is responsible for handling all the core features of the web suite for yagpdb, authentication, adding the bot to servers, and the other basic core functionality.

It also houses a small form validation toolkit through struct tags, this is all kinda messy but one day i hope to improve everything and make it a lot cleaner and easy to work with.
It also houses a small form validation toolkit through struct tags (this is all kinda messy but one day i hope to improve everything and make it a lot cleaner and easy to work with).
4 changes: 2 additions & 2 deletions web/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func SessionMiddleware(inner http.Handler) http.Handler {
token, err := AuthTokenFromB64(cookie.Value)
if err != nil {
if err != ErrNotLoggedIn {
// this could really only happen if the user messes with the session token, or some other bullshit happens (like bad ram i guess)
// this could really only happen if the user messes with the session token, or some other BS happens (like bad ram i guess)
CtxLogger(r.Context()).WithError(err).Error("invalid session")
}

Expand Down Expand Up @@ -347,7 +347,7 @@ func RequireGuildChannelsMiddleware(inner http.Handler) http.Handler {
return
}

// SORT THESE MOTHERFUCKERS
// Sort them
sort.Sort(dutil.Channels(channels))
guild.Channels = channels

Expand Down
Loading

0 comments on commit f4d2a12

Please sign in to comment.