Ejemplo n.º 1
0
def on_message(message):
	if message.channel.is_private and message.author.id != c.user.id:
		console.display("PRIVATE| {0}>{1}>{2}: {3}".format(message.server, message.channel, message.author.display_name, message.content))
		client.send_queue.append(['msg', message.channel, config.cfg.HELPINFO])
	if message.content == '!enable_pickups':
		if message.channel.permissions_for(message.author).manage_channels:
			if message.channel.id not in [x.id for x in bot.channels]:
				newcfg = stats3.new_channel(message.server.id, message.server.name, message.channel.id, message.channel.name, message.author.id)
				bot.channels.append(bot.Channel(message.channel, newcfg))
				client.reply(message.channel, message.author, config.cfg.FIRST_INIT_MESSAGE)
			else:
				client.reply(message.channel, message.author, "this channel allready have pickups configured!")
		else:
			client.reply(message.channel, message.author, "You must have permission to manage channels to enable pickups.")
	elif message.content == '!disable_pickups':
		if message.channel.permissions_for(message.author).manage_channels:
			for chan in bot.channels:
				if chan.id == message.channel.id:
					stats3.delete_channel(message.channel.id)
					bot.channels.remove(chan)
					client.reply(message.channel, message.author, "pickups on this channel have been disabled.")
					return
			client.reply(message.channel, message.author, "pickups on this channel has not been set up yet!") 
		else:
			client.reply(message.channel, message.author, "You must have permission to manage channels to disable pickups.") 
	else:
		for channel in bot.channels:
			if message.channel.id == channel.id:
				console.display("CHAT| {0}>{1}>{2}: {3}".format(message.server, message.channel, message.author.display_name, message.content))
				try:
					channel.processmsg(message.content, message.author)
				except:
					console.display("ERROR| Error processing message: {0}".format(traceback.format_exc()))
Ejemplo n.º 2
0
def new_channel(channel, admin):
    path = "channels/" + channel.id
    shutil.copytree("channels/default", path)
    c = bot.Channel(channel)
    c.update_config("ADMINID", admin.id)
    bot.channels.append(c)
    console.display("SYSTEM| CREATED NEW PICKUP CHANNEL: {0}>{1}".format(
        channel.server.name, channel.name))
Ejemplo n.º 3
0
async def on_message(message):
    #       if message.author.bot:
    #               return
    if isinstance(
            message.channel,
            discord.abc.PrivateChannel) and message.author.id != c.user.id:
        console.display("PRIVATE| {0}>{1}>{2}: {3}".format(
            message.guild, message.channel, message.author.display_name,
            message.content))
        private_reply(message.author, config.cfg.HELPINFO)
    elif message.content == '!enable_pickups':
        if message.channel.permissions_for(message.author).manage_channels:
            if message.channel.id not in [x.id for x in bot.channels]:
                newcfg = stats3.new_channel(message.guild.id,
                                            message.guild.name,
                                            message.channel.id,
                                            message.channel.name,
                                            message.author.id)
                bot.channels.append(bot.Channel(message.channel, newcfg))
                reply(message.channel, message.author,
                      config.cfg.FIRST_INIT_MESSAGE)
            else:
                reply(message.channel, message.author,
                      "this channel allready have pickups configured!")
        else:
            reply(
                message.channel, message.author,
                "You must have permission to manage channels to enable pickups."
            )
    elif message.content == '!disable_pickups':
        if message.channel.permissions_for(message.author).manage_channels:
            for chan in bot.channels:
                if chan.id == message.channel.id:
                    bot.delete_channel(chan)
                    reply(message.channel, message.author,
                          "pickups on this channel have been disabled.")
                    return
            reply(message.channel, message.author,
                  "pickups on this channel has not been set up yet!")
        else:
            reply(
                message.channel, message.author,
                "You must have permission to manage channels to disable pickups."
            )
    elif message.content != '':
        for channel in bot.channels:
            if message.channel.id == channel.id:
                try:
                    await channel.processmsg(message)
                except:
                    console.display(
                        "ERROR| Error processing message: {0}".format(
                            traceback.format_exc()))
Ejemplo n.º 4
0
def process_connection():
    global ready

    console.display('SYSTEM| Logged in as: {0}, ID: {1}'.format(
        c.user.name, c.user.id))

    channels = stats3.get_channels()
    for cfg in channels:
        discord_channel = c.get_channel(cfg['channel_id'])
        if discord_channel == None:
            console.display(
                "SYSTEM| Could not find channel '{0}>{1}#' with CHANNELID '{2}'! Scipping..."
                .format(cfg['server_name'], cfg['channel_name'],
                        cfg['channel_id']))
            #todo: delete channel
        else:
            chan = bot.Channel(discord_channel, cfg)
            bot.channels.append(chan)
            console.display(
                "SYSTEM| '{0}>{1}#' channel init successfull".format(
                    chan.cfg['server_name'], chan.cfg['channel_name']))
    ready = True