(Translated by https://www.hiragana.jp/)
JConfig::AddServer(CfgServer) · SerekKiri/BugHunter@f8a4805 · GitHub
Skip to content

Commit

Permalink
JConfig::AddServer(CfgServer)
Browse files Browse the repository at this point in the history
Piter wez pomoz przy tej funkcji, chce dodawac .\nformatted data a nie mam pomyslu jak
  • Loading branch information
Wandal1337 committed Aug 15, 2018
1 parent 269465a commit f8a4805
Showing 2 changed files with 30 additions and 30 deletions.
58 changes: 29 additions & 29 deletions python/recode/bughunter.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import asyncio
import datetime
import json
import io

#Structure for single server
class CfgServer:
@@ -51,6 +52,9 @@ def readServers(self):
sServer.initialise(server['name'], channelList)
serverList.append(sServer)
return serverList
def addServer(self, CfgServer):
file = open(self.fileName, 'r+')
print(file.read())

#Main class
class BugHunter:
@@ -70,17 +74,6 @@ def isServerAtList(self, serverName):
if(server.name == serverName):
return True
return False
def getAllBotChannelsAtServer(self, server):
parsedServer = 0
for x in self.serverList:
if(x.name == server.name):
parsedServer = x
channels = []
for channel in server.channels:
for x in parsedServer.channelList:
if(channel.name == x):
channels.append(discord.utils.get(self.client.get_all_channels(), server__name=server.name, name=channel.name))
return channels
def findAllOccurrences(self, s, ch):
idxs = []
for i in range(len(s)):
@@ -134,31 +127,39 @@ def loadConfig(self):
self.argSeparator = config.readValue('argSeparator')
self.normalUser = config.readBoolean('normalUser')
self.serverList = data.readServers()
newServer = CfgServer()
data.addServer(newServer)
print('Config loaded')
#SubFunctions
def sendEmbedAtMultipleChannels(self, channels, embed):
for channel in channels:
channel.send(embed=embed)
async def sendEmbedAtBotChannelsAtServer(self, server, embed):
cfgServer = 0
for x in self.serverList:
if x.name == server.name:
cfgServer = x
for channel in server.channels:
for channelname in cfgServer.channelList:
if channel.name == channelname:
await channel.send(embed=embed)
def createHelpEmbed(self):
embed=discord.Embed(title='Help', description='Usage -> bug report bug description (additional -> screenshot)')
embed=discord.Embed(title='Help', description='Usage -> bug report bug description (additional -> screenshot)', color=0xff0000)
embed.set_author(name='BugHunter', url='https://github.com/quritto/DenisAskedMeToDoThisBotForReportBugs', icon_url='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQCaZDPW_-dzsNbodLC5KiAT3BlciGOybFjsUZPRSKI2u7tuQg2BQ')
embed.set_footer(text='BugHunter by Kiritito and R1SK')
embed.set_footer(text='BugHunter by Kiritito, R1SK and Piter')
return embed
def createBugReportEmbed(self, message, parsedMsg):
title = message.author.mention + ' ' + 'sent report'
title = message.author.name + ' ' + 'sent report'
embed=discord.Embed(title=title, description=parsedMsg.args[0], color=0xff0000)
embed.set_author(name='BugHunter', url='https://github.com/quritto/DenisAskedMeToDoThisBotForReportBugs',icon_url='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQCaZDPW_-dzsNbodLC5KiAT3BlciGOybFjsUZPRSKI2u7tuQg2BQ')
embed.set_footer(text='BugHunter by Kiritito and R1SK')
embed.set_footer(text='BugHunter by Kiritito, R1SK and Piter')
return embed
#Main functions
def initialise(self):
print('BugHunter by R1SK & Kiritito')
print('BugHunter by R1SK, Kiritito & Piter')
self.loadConfig()
def handleCommands(self, message, parsedMessage):
if(parsedMessage.command == 'report'):
self.sendEmbedAtMultipleChannels(self.getAllBotChannelsAtServer(message.guild), self.createBugReportEmbed(message, parsedMessage))
else:
self.sendEmbedAtMultipleChannels(self.getAllBotChannelsAtServer(message.guild), self.createHelpEmbed())
#def handleCommands(self, message, parsedMessage):
#if(parsedMessage.command == 'report'):
#self.sendEmbedAtMultipleChannels(self.getAllBotChannelsAtServer(message.guild), self.createBugReportEmbed(message, parsedMessage))
#else:
#self.sendEmbedAtMultipleChannels(self.getAllBotChannelsAtServer(message.guild), self.createHelpEmbed())
#Event handlers
async def onReady(self):
print('Logged in as', self.client.user.name, 'with ID', self.client.user.id)
@@ -168,11 +169,10 @@ async def onMessage(self, message):
return
if(self.isCommand(message) and self.isServerAtList(message.guild.name)):
msg = self.commandAndArgsFromMessage(message)
self.handleCommands(message, msg)
print('parameter count ----->', msg.argCount)
print('command ----->', msg.command)
print('args ----->', msg.args)

if(msg.command == 'report'):
await self.sendEmbedAtBotChannelsAtServer(message.guild, self.createBugReportEmbed(message, msg))
else:
await self.sendEmbedAtBotChannelsAtServer(message.guild, self.createHelpEmbed())
Main = BugHunter()

Main.initialise()
2 changes: 1 addition & 1 deletion python/recode/start.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off
title BugHunter by R1SK and Kiritito
title BugHunter by R1SK Kiritito and Piter
python bughunter.py
pause

0 comments on commit f8a4805

Please sign in to comment.