async def testing(ctx, *, action=None): """These are testing commands, usually for debugging purposes""" if action == 'refresh': tbl, rtbl = p.get_char_sheet(refresh=True) raw_text = mkt.load_item_design_raw(refresh=True) await ctx.send('Refreshed') elif action == 'restart': await ctx.send('Bot will restart') elif action == 'info': server = ctx.server author = ctx.author channel = ctx.channel txt = 'Server: {} (id={})\n'.format(server, server.id) txt += 'Message Author: {} (id={})\n'.format(author, author.id) txt += 'This Channel: {} (id={})\n'.format(channel, channel.id) txt += 'Discord.py version: {}'.format(discord.__version__) await ctx.send(txt) elif action == 'say': if isinstance(text, str): await ctx.send(txt) elif action == 'actions': print(dir(bot)) bot_actions = list(dir(bot)) bot_actions = 'Bot actions:' + ', '.join(bot_actions) await ctx.send(bot_actions) await bot.delete_message(ctx.message) if action == 'restart': print('Attempting to restart') bot.close() quit()
def get_dropship_text(): id2item = request_id2item() ctbl, tbl_i2n, tbl_n2i, rarity = p.get_char_sheet() rooms = rs.get_room_designs() id2roomname = rs.create_reverse_lookup(rooms, 'RoomDesignId', 'RoomName') d = request_dropship() catalog_txt = get_limited_catalog_txt(d, id2item, ctbl, id2roomname) merchantship_txt = get_merchantship_txt(d, id2item) sale_txt = get_sale_text(d, id2item, ctbl) txt = get_dropshipcrew_txt(d, ctbl) txt += '\n\n{}'.format(merchantship_txt) if catalog_txt is not None: txt += '\n\n{}'.format(catalog_txt) if sale_txt is not None: txt += '\n\n{}'.format(sale_txt) txt += '\n\n{}'.format(get_dailyrewards_txt(d, id2item)) if 'News' in d.keys(): txt = '{}\n\n'.format(d['News']) + txt return txt
async def refresh(): write_log(command_prefix + 'refresh', None) tbl, rtbl = p.get_char_sheet(refresh=True) await bot.say('Refreshed')
from __future__ import division from __future__ import print_function from __future__ import unicode_literals from discord.ext import commands import discord import os import logging import pss_prestige as p import pss_market as mkt import time, datetime # ----- Setup --------------------------------------------------------- command_prefix = os.getenv('COMMAND_PREFIX') tbl, rtbl = p.get_char_sheet() # ----- Utilities ----------------------------------------------------- def write_log(log_text, ctx=None): if os.path.isfile("debug") is False: return time_text = datetime.datetime.now().strftime('%Y%m%d %H:%M:%S') ctx_text = '' if ctx is None else \ '{}@{}'.format(ctx.message.author, ctx.message.server) final_text = '{} {}: {}'.format(time_text, ctx_text, log_text) with open("discord-bot.log", "a") as f: f.write(final_text + '\n') print(final_text)
import pss_market as mkt import pss_prestige as p import pss_research as rs import pytz import time, datetime, holidays # ----- Setup --------------------------------------------------------- command_prefix = os.getenv('COMMAND_PREFIX') BOT_OWNER = os.getenv("DISCORD_BOT_OWNER") BOT_VERSION = '0.05' BOT_DESCRIPTION = 'This is a bot for pixel starships' RATE = 3 COOLDOWN = 30.0 # tbl, rtbl = p.get_char_sheet() ctbl, tbl_i2n, tbl_n2i, rarity = p.get_char_sheet() df_research_designs = rs.get_research_designs() raw_text = mkt.load_item_design_raw() df_items = mkt.xmltext_to_df(raw_text) item_rlookup = mkt.get_item_rlookup(df_items) # welcome_txt = """**Welcome to the Pixel Starships Discord!** # This is a place where we can interact with devs and players from other alliances/fleets # 1. :zipper_mouth: you can mute any channel to avoid notifications from that channel # 2. :microphone: #announcements-and-tips-of-the-day are for anything really important on PSS, as well as a means for the devs to post announcements # 3. :bulb: if you have any suggestions for the game, you can post them in #suggestion-posts. previously discussed suggestions are in #summaries # 4. :beetle: #game-support is for bugs, etc. \@@TheRealTiffany is usually there # 5. :robot: We have a #dolores-bot-room. type “`/help`” to find out how to use this bot for character stats/prestige combos, and item prices/stats. # 6. :art: Get a Discord color by posting a screenshot with your trophy level in #screenshots # 7. :dove: The usual guidelines for any forum apply (try to be civil, don’t spam, etc)."""