Exemplo n.º 1
0
    async def create(self, ctx, ship: int, maxmembers: int, *, questname: str):
        """Creates a group."""

        with self.lock:
            users = ReadFile('cogs/json/users.json')
            if ctx.message.author.id in users:
                file = ReadFile('cogs/json/matchmaking.json')

                try:
                    id = file['groups'][-1]['id'] + 1
                except Exception:
                    id = 0

                file['groups'].append({
                    "id": id,
                    "quest": questname,
                    "ship": ship,
                    "owner": ctx.message.author.id,
                    "members": [ctx.message.author.id],
                    "maxmembers": maxmembers
                })
                if not discord.utils.get(ctx.message.server.roles,
                                         name="Group {}".format(id)):
                    await self.bot.create_role(ctx.message.server,
                                               name="Group {}".format(id))

                await asyncio.sleep(1)
                await self.bot.add_roles(
                    ctx.message.author,
                    discord.utils.get(ctx.message.server.roles,
                                      name="Group {}".format(id)))

                everyone = discord.PermissionOverwrite(read_messages=False)
                mine = discord.PermissionOverwrite(read_messages=True,
                                                   send_messages=True)

                await self.bot.create_channel(
                    ctx.message.server, 'group-{}'.format(id),
                    (ctx.message.server.default_role, everyone),
                    (discord.utils.get(ctx.message.server.roles,
                                       name="Group {}".format(id)), mine))

                WriteFile('cogs/json/matchmaking.json', file)

                message = "@here A group for ``{}`` on Ship {} has been created by ``{}``. Type ``!lfp join {}`` to join!".format(
                    questname, ship, ctx.message.author.nick, id)
                await self.bot.send_message(
                    discord.Object("174958246837223425"), message)
            else:
                await self.bot.say(
                    "You are not registered! Type ``!help reg``.")
Exemplo n.º 2
0
    async def reg(self, ctx, *, playerID: str):
        """Register your Player ID and receive full access to the server"""

        with self.lock:
            file = ReadFile('cogs/json/users.json')
            file.update(
                {"{}".format(ctx.message.author.id): "{}".format(playerID)})
            WriteFile('cogs/json/users.json', file)

            await self.bot.add_roles(
                ctx.message.author,
                discord.utils.get(ctx.message.server.roles, name="LFP"))
            await self.bot.say("{} Registered!".format(
                ctx.message.author.mention))
Exemplo n.º 3
0
    async def remove(self, ctx, member: str):
        """Removes a selected member from a group. GROUP OWNER ONLY"""

        with self.lock:
            file = ReadFile('cogs/json/matchmaking.json')
            index = SearchGroup(id)

            if ctx.message.author.id == file['groups'][index]['owner']:
                try:
                    await self.bot.remove_roles(
                        ctx.message.server.get_member(member),
                        discord.utils.get(ctx.message.server.roles,
                                          name="Group {}".format(id)))
                    file['groups'][index]['members'].remove(member)
                    WriteFile('cogs/json/matchmaking.json', file)

                    await self.bot.say(
                        "{} Member ``{}`` removed from the ``{}`` group.".
                        format(ctx.message.author.mention, member,
                               file['groups'][index]['quest']))
                except Exception as e:
                    await self.bot.say(
                        "{} Member ``{}`` not found in the ``{}`` group.".
                        format(ctx.message.author.mention, member,
                               file['groups'][index]['quest']))
            else:
                await self.bot.say(
                    "{} You are not the owner of the group.".format(
                        ctx.message.author.mention))
Exemplo n.º 4
0
    async def remove(self, ctx, groupID: int, *, membername: str):
        """Remove a member from a group."""

        if ctx.message.author.id in admins:
            with self.lock:
                file = ReadFile('cogs/json/matchmaking.json')
                id = SearchGroup(groupID)

                try:
                    member = SearchMember(membername)

                    await self.bot.remove_roles(
                        ctx.message.server.get_member(member),
                        discord.utils.get(ctx.message.server.roles,
                                          name="Group {}".format(id)))
                    file['groups'][id]['members'].remove(member)
                    WriteFile('cogs/json/matchmaking.json', file)

                    await self.bot.say(
                        "{} Member ``{}`` removed from the ``{}`` group.".
                        format(ctx.message.author.mention, membername,
                               file['groups'][id]['quest']))
                except Exception as e:
                    await self.bot.say(
                        "{} Member ``{}`` not found in the ``{}`` group.".
                        format(ctx.message.author.mention, membername,
                               file['groups'][id]['quest']))
Exemplo n.º 5
0
    async def finish(self, ctx, groupID: int):
        """Finishes a group."""

        if ctx.message.author.id in admins:
            with self.lock:
                try:
                    index = SearchGroup(groupID)
                    file = ReadFile('cogs/json/matchmaking.json')

                    server = ctx.message.server
                    for user in file['groups'][index]['members']:
                        await self.bot.remove_roles(
                            server.get_member(user),
                            discord.utils.get(server.roles,
                                              name="Group {}".format(groupID)))

                    await self.bot.delete_channel(
                        discord.utils.get(server.channels,
                                          name="group-{}".format(groupID)))
                    await self.bot.delete_role(
                        server,
                        discord.utils.get(server.roles,
                                          name="Group {}".format(groupID)))

                    file['groups'].pop(index)

                    WriteFile('cogs/json/matchmaking.json', file)
                except:
                    await self.bot.say("Something went wrong.")
Exemplo n.º 6
0
    async def leave(self, ctx):
        """Leaves the selected group."""

        with self.lock:
            if ctx.message.channel.name.startswith('group'):
                groupID = ctx.message.channel.name.split('-')[1]
                file = ReadFile('cogs/json/matchmaking.json')
                index = SearchGroup(int(groupID))

                #print(file['groups'][groupID]['owner'])
                #print(file['groups'][index]['owner'])

                if ctx.message.author.id in file['groups'][index]['members']:
                    await self.bot.remove_roles(
                        ctx.message.author,
                        discord.utils.get(ctx.message.server.roles,
                                          name="Group {}".format(groupID)))

                    file['groups'][index]['members'].remove(
                        ctx.message.author.id)

                    WriteFile('cogs/json/matchmaking.json', file)

                    await self.bot.say(
                        "{} You have been removed from the ``{}`` group.".
                        format(ctx.message.author.mention,
                               file['groups'][index]['quest']))
                else:
                    await self.bot.say("{} You are not in that group.".format(
                        ctx.message.author.mention))
            else:
                await self.bot.say(
                    "{} Group commands must be used in a group channel.".
                    format(ctx.message.author.mention))
Exemplo n.º 7
0
    async def finish(self, ctx):
        with self.lock:
            if ctx.message.channel.name.startswith('group'):
                id = ctx.message.channel.name.split('-')[1]

                index = SearchGroup(int(id))
                file = ReadFile('cogs/json/matchmaking.json')

                if ctx.message.author.id == file['groups'][index]['owner']:
                    server = self.bot.get_server("80900839538962432")
                    for user in file['groups'][index]['members']:
                        await self.bot.remove_roles(
                            server.get_member(user),
                            discord.utils.get(ctx.message.server.roles,
                                              name="Group {}".format(id)))

                    await self.bot.delete_channel(
                        discord.utils.get(ctx.message.server.channels,
                                          name="group-{}".format(id)))
                    await self.bot.delete_role(
                        server,
                        discord.utils.get(ctx.message.server.roles,
                                          name="Group {}".format(id)))

                    file['groups'].pop(index)

                    WriteFile('cogs/json/matchmaking.json', file)
                else:
                    await self.bot.say(
                        "{} Only the group owner can finish the quest.".format(
                            ctx.message.author.mention))
            else:
                await self.bot.say(
                    "{} Group commands must be used in a group channel.".
                    format(ctx.message.author.mention))
Exemplo n.º 8
0
    async def join(self, ctx, id: int):
        """Joins a group."""

        with self.lock:
            users = ReadFile('cogs/json/users.json')
            if ctx.message.author.id in users:
                try:
                    file = ReadFile('cogs/json/matchmaking.json')
                    index = SearchGroup(id)

                    if ctx.message.author.id not in file['groups'][index][
                            'members']:
                        try:
                            await self.bot.add_roles(
                                ctx.message.author,
                                discord.utils.get(ctx.message.server.roles,
                                                  name="Group {}".format(id)))
                            file['groups'][index]['members'].append(
                                ctx.message.author.id)
                            WriteFile('cogs/json/matchmaking.json', file)

                            await self.bot.say(
                                "{} Joined the ``{}`` group, owned by ``{}``.".
                                format(ctx.message.author.mention,
                                       file['groups'][index]['quest'],
                                       users[file['groups'][index]['owner']]))

                        except Exception as e:
                            await self.bot.say(
                                "{} Could not find the requested group. Please check the #group-board channel."
                                .format(ctx.message.author.mention))
                    else:
                        await self.bot.say(
                            "{} You are already in that group.".format(
                                ctx.message.author.mention))
                except:
                    await self.bot.say(
                        "{} Could not find a group with that ID. Check #groups-board for the right ID."
                        .format(ctx.message.author.mention))
            else:
                await self.bot.say(
                    "You are not registered! Type ``!help reg``.")
Exemplo n.º 9
0
    async def leave(self, ctx, id: int):
        """Leaves the selected group."""

        with self.lock:
            file = ReadFile('cogs/json/matchmaking.json')
            index = SearchGroup(id)

            if ctx.message.author.id in file['groups'][index]['members']:
                await self.bot.remove_roles(
                    ctx.message.author,
                    discord.utils.get(ctx.message.server.roles,
                                      name="Group {}".format(id)))

                file['groups'][index]['members'].remove(ctx.message.author.id)

                WriteFile('cogs/json/matchmaking.json', file)

                await self.bot.say(
                    "{} You have been removed from the ``{}`` group.".format(
                        ctx.message.author.mention,
                        file['groups'][id]['quest']))
            else:
                await self.bot.say("{} You are not in that group.".format(
                    ctx.message.author.mention))
Exemplo n.º 10
0
#-----------Signal processing code-----------
from functions import ReadFile, filteremg, filter_with_set_values, NotchFilter, BandPassFilter, Compute_RMS, LowPassButter, CreateThreshold, FindActivity, FindPedalStrokeStart
import matplotlib.pyplot as plt
import numpy as np
import math

from crud import upload_image_file
import six
# ---------------------Python code for signal processing-------------------------

#Fetching EMG file
data = ReadFile('OpenBCI-RAW-2018-11-07_14-47-55_biking_fixed_Reb.txt')
SamplFreq = 250

#Creating vectores
pin1 = []
pin2 = []
pin3 = []
pin4 = []
pin5 = []
pin6 = []
pin7 = []
pin8 = []
TimeStamp = []

Fs = 250

#Data inserting into their vectors
for emgf_tmp in data:
    pin1.append(emgf_tmp[' Pin1']
                )  #Adding measures from pin 1 - Gastrocnemius Laterialis
Exemplo n.º 11
0
from functions import ReadFile
import matplotlib.pyplot as plt

#Sæki gögnin úr EMG skrá
data = ReadFile('OpenBCI-RAW-2018-09-26_18-11-18.txt')

#bý til tóma vektora
pin1 = []
pin2 = []
pin3 = []
pin4 = []
pin5 = []
pin6 = []
pin7 = []
pin8 = []

#hleð gögnum inn í viðeigandi vektora
for x in data:
	pin1.append(x[' Pin1']) #Bæti við mælingum frá pinna 1
	pin2.append(x[' Pin2']) #Bæti við mælingum frá pinna 2
	pin3.append(x[' Pin3']) #Bæti við mælingum frá pinna 3
	pin4.append(x[' Pin4']) #Bæti við mælingum frá pinna 4
	pin5.append(x[' Pin5']) #Bæti við mælingum frá pinna 5
	pin6.append(x[' Pin6']) #Bæti við mælingum frá pinna 6
	pin7.append(x[' Pin7']) #Bæti við mælingum frá pinna 7
	pin8.append(x[' Pin8']) #Bæti við mælingum frá pinna 8


#Change all values in the lists from string to number
pin1 = list(map(float, pin1))
pin2 = list(map(float, pin2))