Browse Source

v0.3 Release

tags/v0.3.0
roxie 7 years ago
parent
commit
bf0ab2ced2
7 changed files with 48 additions and 35 deletions
  1. +12
    -6
      cogs/Admin.py
  2. +4
    -4
      cogs/Twitch.py
  3. +2
    -2
      cogs/selfAssign.py
  4. +1
    -1
      config/config.json
  5. +15
    -9
      config/config.py
  6. +1
    -1
      config/settings.ini
  7. +13
    -12
      main.py

+ 12
- 6
cogs/Admin.py View File

if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
else: else:
if module in self.con.serverconfig[ctx.message.server.id]:
if setting in self.con.serverconfig[ctx.message.server.id]:
if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]: if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]:
self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 1 self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 1
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say("'{}' was enabled!".format(setting)) return await self.bot.say("'{}' was enabled!".format(setting))
else: else:
self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 0 self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 0
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say("'{}' was disabled :cry:".format(setting)) return await self.bot.say("'{}' was disabled :cry:".format(setting))
else: else:
return await self.bot.say("That module dont exist fam. You made the thing") return await self.bot.say("That module dont exist fam. You made the thing")
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
self.con.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id self.con.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention)) return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention))


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
self.con.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id self.con.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention)) return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention))


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention)) return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention))


@bot.command(pass_context=True, visible=False)
async def set_customwelcomemessage(self, ctx, *message):
self.con.serverconfig[ctx.message.server.id]["greets"]["custom_message"] = ' '.join(message)
self.con.updateconfig()
return await self.bot.say("Custom message set to '{}'".format(' '.join(message)), delete_after=10)

@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)
async def changeavatar(self, ctx, url=None): async def changeavatar(self, ctx, url=None):
""" """

+ 4
- 4
cogs/Twitch.py View File

else: else:
if not self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"]: if not self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"]:
self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 1 self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 1
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.reply("Whitelist for Twitch shilling has been enabled.") return await self.bot.reply("Whitelist for Twitch shilling has been enabled.")
else: else:
self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 0 self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 0
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.reply("Whitelist for Twitch shilling has been disabled.") return await self.bot.reply("Whitelist for Twitch shilling has been disabled.")


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)
if option in ['+', 'add']: if option in ['+', 'add']:
for user in ctx.message.mentions: for user in ctx.message.mentions:
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id) self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id)
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
whitelist_count += 1 whitelist_count += 1
return await self.bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count)) return await self.bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count))


for user in ctx.message.mentions: for user in ctx.message.mentions:
if user.id in self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"]: if user.id in self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"]:
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].remove(user.id) self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].remove(user.id)
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
whitelist_count += 1 whitelist_count += 1
return await self.bot.say('{} user(s) have been removed to the whitelist'.format(whitelist_count)) return await self.bot.say('{} user(s) have been removed to the whitelist'.format(whitelist_count))



+ 2
- 2
cogs/selfAssign.py View File

return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
else: else:
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id) self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id)
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say('Role "{}" added'.format(str(role))) return await self.bot.say('Role "{}" added'.format(str(role)))


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)


if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]:
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id) self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id)
self.con.updateconfig(self.con.serverconfig)
self.con.updateconfig()
return await self.bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role))) return await self.bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role)))
else: else:
return await self.bot.say("That role was not in the list.") return await self.bot.say("That role was not in the list.")

+ 1
- 1
config/config.json View File

{"304048071963312130": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": ""}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 1, "twitch-channel": "304048071963312130", "whitelist": {"enabled": 0, "list": ["259869304369971200"]}}}, "175285455204384768": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": ""}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 1, "twitch-channel": "334812611575283712", "whitelist": {"enabled": 0, "list": []}}}}
{"175285455204384768": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message:": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}, "304048071963312130": {"greets": {"enabled": 1, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message:": "Be sure to read the rules."}, "goodbyes": {"enabled": 1, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": ["307330606348632064", "308083509866659850"]}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}}

+ 15
- 9
config/config.py View File

import json import json
from pprint import pprint




class Config(): class Config():
"greets": { "greets": {
"enabled": 0, "enabled": 0,
"welcome-channel": "", "welcome-channel": "",
"member-role": ""
"member-role": "",
"custom-message": "",
"default-message:": "Be sure to read the rules."
}, },
"goodbyes": { "goodbyes": {
"enabled": 0, "enabled": 0,
"goodbye-channel": ""
"goodbye-channel": "",
}, },
"self-assign_roles": { "self-assign_roles": {
"enabled": 0, "enabled": 0,


async def on_server_join(self, server): async def on_server_join(self, server):
self.serverconfig[server.id] = self.serverconfig_template["example"] self.serverconfig[server.id] = self.serverconfig_template["example"]
self.updateconfig(self.serverconfig)
self.updateconfig()


async def on_server_remove(self, server): async def on_server_remove(self, server):
self.serverconfig.pop(server.id) self.serverconfig.pop(server.id)
self.updateconfig(self.serverconfig)
self.updateconfig()


def load_config(self): def load_config(self):
with open('config/config.json', 'r') as config_file: with open('config/config.json', 'r') as config_file:
return json.load(config_file) return json.load(config_file)


def updateconfig(self, config):
def updateconfig(self):
with open('config/config.json', 'w') as conf_file: with open('config/config.json', 'w') as conf_file:
json.dump(config, conf_file)
json.dump(self.serverconfig, conf_file)
pprint(self.serverconfig)


def config_errorcheck(self): def config_errorcheck(self):
# Checks for errors in the config files and fixes them automatically
# TODO: Fix so that it checks for problems in children of module settings. i.e children of 'greets'
# TODO: Fix issue where a setting can be enabled when it has no channel to post to.
for server in self.bot.servers: for server in self.bot.servers:
if server.id not in self.serverconfig: if server.id not in self.serverconfig:
self.serverconfig[server.id] = self.serverconfig_template["example"] self.serverconfig[server.id] = self.serverconfig_template["example"]
self.updateconfig(self.serverconfig)
self.updateconfig()
print( print(
"WARNING: The config file for {} was not found. A template has been loaded and saved. All modules are turned off by default.".format( "WARNING: The config file for {} was not found. A template has been loaded and saved. All modules are turned off by default.".format(
server.name.upper())) server.name.upper()))
if module_setting not in self.serverconfig[server.id]: if module_setting not in self.serverconfig[server.id]:
self.serverconfig[server.id][module_setting] = self.serverconfig_template["example"][ self.serverconfig[server.id][module_setting] = self.serverconfig_template["example"][
module_setting] module_setting]
self.updateconfig(self.serverconfig)
self.updateconfig()
print( print(
"WARNING: The config file for {} was missing the {} module. This has been fixed with the template version. It is disabled by default.".format( "WARNING: The config file for {} was missing the {} module. This has been fixed with the template version. It is disabled by default.".format(
server.name.upper(), module_setting.upper())) server.name.upper(), module_setting.upper()))
print("")




def setup(bot): def setup(bot):

+ 1
- 1
config/settings.ini View File

[Credentials] [Credentials]
; Put your token here. ; Put your token here.
Token = MzA4MDc3ODg3MDYyNTQwMjg5.DEwCbA.Bj933S3guhHY4KnbtZyuwESJ_b4
Token = MzA4MDc3ODg3MDYyNTQwMjg5.DFBkcw.RxM8VtNHgt5hDyjuFwPT2X61guw


[RoxBot] [RoxBot]
OwnerID = 142735312626515979 OwnerID = 142735312626515979

+ 13
- 12
main.py View File

#!/usr/env python

############## ##############
# To-do List # # To-do List #
############## ##############


# High Priority # # High Priority #
# TODO: Command Review, look at all commands and flesh them out. Maybe some randomised dialogue so that not every command has only one response. Make sure user experience feels nice.
# TODO: Also self delete timers.
# TODO: Full Docs on the commands and their use
# TODO: iam remove command
# TODO: Welcome and goodbye default messages and changable messages
# TODO: Fix Config Bug


# Mid Priority # # Mid Priority #
# TODO: Move away from using ID's for everthing. Maybe replace list with dict # TODO: Move away from using ID's for everthing. Maybe replace list with dict
# TODO: On member role assign, welcome member using on_member_update # TODO: On member role assign, welcome member using on_member_update


# Low Priority # # Low Priority #
# TODO: Command Review, look at all commands and flesh them out. Make sure user experience feels nice
# TODO: Better help menu- AutoGen using <command>.help # TODO: Better help menu- AutoGen using <command>.help
# TODO: Overwatch stats - Using Overwatch-API lib # TODO: Overwatch stats - Using Overwatch-API lib
# TODO: Add check for no channel id when a module is enabled # TODO: Add check for no channel id when a module is enabled
# TODO: Maybe some randomised dialogue so that not every command has only one response.



import random
import configparser import configparser


import discord import discord


__version__ = '0.3.0' __version__ = '0.3.0'



settings = configparser.ConfigParser() settings = configparser.ConfigParser()
settings.read('config/settings.ini') settings.read('config/settings.ini')


""" """
if not con.serverconfig[member.server.id]["greets"]["enabled"]: if not con.serverconfig[member.server.id]["greets"]["enabled"]:
return return

print("Passes Enabled Check")
if con.serverconfig[member.server.id]["greets"]["custom-message"]:
message = con.serverconfig[member.server.id]["greets"]["custom-message"]
else:
message = con.serverconfig[member.server.id]["greets"]["default-message"]
print("passed message check")
em = discord.Embed( em = discord.Embed(
title="Welcome to {}!".format(member.server), title="Welcome to {}!".format(member.server),
description='Hey {}! Welcome to {}! Be sure to read the rules.'.format(member.mention, member.server),
description='Hey {}! Welcome to **{}**! {}'.format(member.mention, member.server, message),
colour=0xDEADBF) colour=0xDEADBF)


if con.serverconfig[member.server.id]["greets"]["welcome-channel"]: if con.serverconfig[member.server.id]["greets"]["welcome-channel"]:
channel = discord.Object(con.serverconfig[member.server.id]["greets"]["welcome-channel"]) channel = discord.Object(con.serverconfig[member.server.id]["greets"]["welcome-channel"])
else: else:
channel = member.server.default_channel channel = member.server.default_channel
print("passed channel getting")
return await bot.send_message(channel,embed=em) return await bot.send_message(channel,embed=em)




description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=0xDEADBF)) description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=0xDEADBF))





if __name__ == "__main__": if __name__ == "__main__":
bot.run(token) bot.run(token)

Loading…
Cancel
Save