Ejemplo n.º 1
0
async def failed_reaction(message):
  logging.info('Failed to add reaction.')
  if utils.is_pm(message.channel): return
  channel_settings = await get_guild_setting(message.guild.id, "channel-"+str(message.channel.id), default={})
  if not "AskedForReactPerms" in channel_settings.keys():
    channel_settings["AskedForReactPerms"] = True
    await set_guild_setting(message.guild.id, "channel-"+str(message.channel.id), channel_settings)
  elif channel_settings["AskedForReactPerms"]:
    logging.debug("Already asked up for "+str(message.channel.id))
    return
  await send2owner("I do not have `Add Reactions` permission in `"+message.guild.name+"/"+message.channel.name+"`")
Ejemplo n.º 2
0
async def failed_message(where, want_perm):
  logging.info('Failed to send message.')
  if utils.is_pm(where): return
  channel_settings = await get_guild_setting(where.guild.id, "channel-"+str(where.id), default={})
  key = "AskedFor"+want_perm
  if not key in channel_settings.keys():
    channel_settings[key] = True
    await set_guild_setting(where.guild.id, "channel-"+str(where.id), channel_settings)
  elif channel_settings[key]:
    logging.debug("Already asked for "+key+" in "+str(where.id))
    return
  await send2owner("I do not have `"+want_perm+"` permission in `"+where.guild.name+"/"+where.name+"`")
Ejemplo n.º 3
0
async def vc_checks(message):
  if utils.is_pm(message.channel):
    await write_message(message.channel, "This is a private message. Do the command in a server.")
    return
  if message.author.voice == None:
    await write_message(message.channel, "You must be in a voice channel to use this command.")
    return
  if message.author.voice.channel == None:
    await write_message(message.channel, "You must be in a voice channel to use this command.")
    return
  if message.guild.id in players.keys():
    if not players[message.guild.id].channel == message.author.voice.channel:
      await write_message(message.channel, "You must be in the same voice channel as the bot to use this command.")
      return
  return message.author.voice.channel
Ejemplo n.º 4
0
async def rescan(dclient, message, match):
  if utils.is_pm(message.channel):
    await write_message(message.channel, "This is a private message. Do the command in a server.")
    return

  users = settings.readSavedVar("users", default={})
  compiled = ""
  for m in message.guild.members:
    ret = None
    if str(m.id) in users.keys(): ret = users[str(m.id)]
    if "{} in {}".format(m.id, message.guild.id) in users.keys(): ret = users["{} in {}".format(m.id, message.guild.id)]
    if ret == None: continue
    if ret == False: ret = "Is a football."
    compiled = "{}{} - {}\n".format(compiled, m.mention, ret)
  if compiled == "":
    await write_message(message.channel, "No users found with warnings in this server. :thumbsup:")
    return
  await write_message(message.channel, compiled)
Ejemplo n.º 5
0
async def dump_roles(dclient, message, match):
  if utils.is_pm(message.channel):
    await write_message(message.channel, "This is a private message. Do the command in a server.")
    return
  await write_message(message.channel, "```"+utils.better_str([str(r.id)+" - "+r.name for r in message.guild.roles]).replace(", ", "\n")+"```")
Ejemplo n.º 6
0
  async def on_message(self, message):
    global cell_phone
    global cake_nom
    appinf = await quarter.application_info()
    isDM = utils.is_pm(message.channel)
    owner = message.author.id == appinf.owner.id and (self.user in message.mentions or isDM)
    requested = message.content.startswith("qb ")

    features = []
    if not message.guild == None: features = await get_guild_setting(message.guild.id, "features", default=[])

    # Ignore own messages
    if message.author == self.user: return

    # Ignore bots
    if message.author.bot: return

    if isinstance(message.content.lower(), str):
      check1 = ACIF2.command_matcher()
      if "snow_angels" in features:
        for k, v in SA.message_checks.items():
          check1.add(k, v)
      do = check1.match(message.content.lower())
      if isinstance(do, str):
        message_link = "https://discordapp.com/channels/{}/{}/{}".format(message.guild.id, message.channel.id, message.id)
        await do_warn(message.author, "{}\nChannel: <#{}>\n{}".format(do, message.channel.id, message_link))
      elif not do == None:
        await do(self, message, match)

    users = settings.readSavedVar("users", default={})
    ret = None
    if str(message.author.id) in users.keys(): ret = users[str(message.author.id)]
    if not isDM:
      if "{} in {}".format(message.author.id, message.guild.id) in users.keys(): ret = users["{} in {}".format(message.author.id, message.guild.id)]
    if ret == "CAKE_NOM":
      if cake_nom < time.time():
        cake_nom = time.time() + 1800
        await message.add_reaction("<:nom2:749701952790724749>")

    # _should_ convert most accent marks
    conv = message.content.lower()
    conv = conv.replace(":regional_indicator_", "")
    # Need to take off the other colon too
    conv = conv.replace(":", "")

    for i in range(0, 3):
      conv = conv.replace("heck"[i]*2, "heck"[i])

    conv2 = unidecode.unidecode(conv)

    # Feel free to append
    heck_check = ["heck", "ʞɔǝɥ", "ʰᵉᶜᵏ", "h3ck", "həck"]

    orig = conv.lower()
    rep = conv.lower()
    for i in heck_check:
      rep = re.sub("\\b{}\\b".format(i), "", rep, flags=re.IGNORECASE)

    if not orig == rep:
      try:
        await message.add_reaction(chr(127469))
        await message.add_reaction(chr(127466))
        await message.add_reaction(chr(127464))
        await message.add_reaction(chr(127472))
      except:
        pass

    if "baka baka baka" in message.content.lower():
      if time.time() > cell_phone:
        await write_message(message.channel, "_Cell phone noises._")
      cell_phone = time.time() + 3600

    if isinstance(ret, str):
      if ret.startswith("NAME_MESSAGE"):
        nick = ret.replace("NAME_MESSAGE ", "")
        if not message.author.nick == nick:
          try:
            await message.author.edit(nick=nick, reason="Message name lock enabled for this user.")
            logging.info('Message namelock: {}'.format(nick))
          except Exception as e:
            log.exception(e)

    # Ignore normal messages
    if not owner and not requested: return

    # Ignore DMs from non-owner
    if utils.is_pm(message.channel) and not owner: return

    if owner:
      cleaned = utils.remove_activation_text(message, sendback=True)
      mentions = cleaned[1]
      cleaned = cleaned[0]
    elif requested:
      cleaned = message.content.replace("qb ", "")

    splitup = cleaned.lower().split("\n")
    for i in range(len(splitup)):
      checkme = splitup[i]
      check = ACIF2.command_matcher()

      if owner:
        check.add("sudo reboot", shutdown)
      elif requested:
        check.add("ping", "Pong!")
        if message.author.guild_permissions.manage_roles:
          check.add("enable", enable)
          check.add("disable", disable)
          check.add("dump roles", dump_roles)
        if message.author.guild_permissions.kick_members:
          check.add("add", add_warn)
          check.add("set", set_warn)
          check.add("scan", rescan)
          # Radio controls
          check.add("play", play)
          check.add("vol", vol)
          check.add("stop", stop)
          check.add("lvl football", lvl_football)

      check.add(["list commands", "help"], utils.better_str(check.get_list()))

      do, match = check.match(checkme, return_match=True)
      if isinstance(do, str):
        await write_message(message.channel, do)
      elif not do == None:
        await do(self, message, match)

      if "OaU" in features:
        onandup = await get_guild_setting(message.guild.id, "OaU", default={})
        prep = OaU.role_giver(onandup, ACIF2)
        ret = await prep.on_message(message, message.author.id == appinf.owner.id, checkme.lower())
        if isinstance(ret, str):
          await write_message(message.channel, ret)
        elif not ret == None:
          await set_guild_setting(message.guild.id, "OaU", ret)
          await write_message(message.channel, ":thumbsup:", delete_after=60)