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

Commit

Permalink
progress on swear, bit of refactors, updated readme, nickname command
Browse files Browse the repository at this point in the history
  • Loading branch information
djetelina committed May 19, 2016
1 parent 2b01fbf commit 0c60334
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 25 deletions.
23 changes: 14 additions & 9 deletions cogs/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,30 @@ async def _sf(self):
time = get_time()
await s.destructmsg("**San Francisco**: {} (UTC-7)".format(time["sf"]), 30, self.bot)

@commands.command(description=desc.ss, brief=desc.ss)
@commands.command(description=desc.steam_status, brief=desc.steam_status)
async def steamstatus(self):
steam_api = 'http://is.steam.rip/api/v1/?request=SteamStatus'
with aiohttp.ClientSession() as session:
async with session.get('http://is.steam.rip/api/v1/?request=SteamStatus')as resp:
async with session.get(steam_api)as resp:
data = await resp.json()
if str(data["result"]["success"]) == "True":
ses = ("**Session Logon:** " + data["result"]["SteamStatus"]["services"]["SessionsLogon"] + "\n")
com = ("**Steam Community:** " + data["result"]["SteamStatus"]["services"]["SteamCommunity"] + "\n")
eco = ("**Steam Economy:** " + data["result"]["SteamStatus"]["services"]["IEconItems"] + "\n")
# lead = ("Leaderboards: " + data["result"]["SteamStatus"]["services"]["LeaderBoards"] + "\n")
login = (data["result"]["SteamStatus"]["services"]["SessionsLogon"]).capitalize
community = (data["result"]["SteamStatus"]["services"]["SteamCommunity"]).capitalize
economy = (data["result"]["SteamStatus"]["services"]["IEconItems"]).capitalize
leaderboards = (data["result"]["SteamStatus"]["services"]["LeaderBoards"]).capitalize

reply = """__**Steam Status**__
**Login servers:** {}
**Community servers:** {}
**Economy servers:** {}""".format(login, community, economy)

header = "__**Steam Status**__\n\n"
reply = header + ses + com + eco
else:
reply = "Failed - Error: " + data["result"]["error"]

await s.destructmsg(reply, 30, self.bot)

@commands.command(description=desc.rd, brief=desc.rd)
@commands.command(description=desc.releasae_dates, brief=desc.releasae_dates)
async def rd(self):
dates = {
"Overwatch": datetime(2016, 5, 24, 0, 0, 0),
Expand Down
5 changes: 5 additions & 0 deletions cogs/restricted.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ async def avatar(self, image: str):
async def play(self, *, playing: str):
await self.bot.change_status(game=discord.Game(name=playing))

@commands.command(pass_context=True, hidden=True, description="not for you")
@checks.is_scream()
async def nick(self, ctx, *, nick: str):
await self.bot.change_nickname(ctx.message.server.me , nick)

@commands.command(hidden=True, pass_context=True, description=desc.rtfh, brief=desc.rtfhb)
@checks.mod_or_permissions(manage_messages=True)
async def rtfh(self, ctx, target: str, cmd: str):
Expand Down
43 changes: 30 additions & 13 deletions cogs/swear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import simplify as s
import random


"""
Expand Down Expand Up @@ -44,20 +45,36 @@ async def warn_user(self):
s.whisper(self.user, "I'm warning you", self.bot)


async def message(bot, message):
"""
after you decide he used something for which you want to give him a point:
class Swear:
def __init__(self, bot):
self.bot = bot
self.greylist = ["fuck", "shit", "cunt"]
self.blacklist = ["nigga", "nigger", "kys", "fuck you", "fuck u"]
self.ignore = "180842549873737728"

async def message(self, message):
if message.author.id is not self.ignore:
self.check_grey(message)
self.check_black(message)

async def check_grey(self, message):
for word in self.greylist:
if word in message.content:
self.trigger(message)
return

if message.author in watchlist:
watchlist['message.author'].new()
else:
Warns(message.author, bot)
async def check_black(self, message):
for word in self.blacklist:
if word in message.content:
self.trigger(message)
return

Only create the logic for detecting the bad words
async def trigger(self, message):
if message.author in watchlist:
watchlist['message.author'].new()
else:
Warns(message.author, self.bot)

If you want grey words to have different weight than black words
we can have new_grey and new_black methods instead of new, add different amount of points
Then for every point loop.create_task(self.decay)
"""
pass

def setup(bot):
bot.add_cog(Swear(bot))
11 changes: 8 additions & 3 deletions descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
Description strings
"""

main = """Bot for Idiotech's Discord by iScrE4m
main = """Bot for Idiotech's Discord
Owner: iScrE4m
Contributors: Extra_Random
Source code: https://github.com/iScrE4m/IdiotechDiscordBot
Request a feature: https://github.com/iScrE4m/IdiotechDiscordBot/issues
Commands can have subcommands, you can type !help for those too
For example: !help giveaway open"""
Expand Down Expand Up @@ -93,8 +98,8 @@
time_london = "Checks local time in London and it's GMT position"
time_ny = "Checks local time in New York and it's GMT position"
time_sf = "Checks local time in San Francisco and it's GMT position"
rd = "List of games and countdown till their releases"
ss = "Check Status of Steam Servers"
releasae_dates = "List of games and countdown till their releases"
steam_status = "Check Status of Steam Servers"

"""
STATS
Expand Down
10 changes: 10 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Bot for Discord server of Idiotech

## Rules for developing

* Don't collect any user information (not even chat logs)
* Make your code readable by humans
* Document if you can

## Request a feature

To request a feature please use [issue tracker](https://github.com/iScrE4m/IdiotechDiscordBot/issues)

## Requirements

* Python 3.5+
Expand Down

0 comments on commit 0c60334

Please sign in to comment.