Ejemplo n.º 1
0
def instant_death(user_id,
                  role,
                  deathType,
                  answer=Mailbox().log(''),
                  recursive=''):
    """Eliminate the given user."""

    # If the user was reporter or mayor, get rid of that.
    if dy.get_mayor() == user_id:
        dy.kill_mayor()
        answer.remove_proms(user_id)
    if dy.get_reporter() == user_id:
        dy.kill_reporter()
        answer.remove_proms(user_id)

    for channel_id in db.get_secret_channels("Graveyard"):
        answer.edit_cc(channel_id, user_id, 1)

    # Change all channel settings
    for channel_id in db.channel_change_all(user_id, 1, 4):
        answer.edit_cc(channel_id, user_id, 4)
    for channel_id in db.channel_change_all(user_id, 2, 4):
        answer.edit_cc(channel_id, user_id, 4)
    for channel_id in db.channel_change_all(user_id, 5, 4):
        answer.edit_cc(channel_id, user_id, 4)

    # Change abducted settings
    for channel_id in db.channel_change_all(user_id, 3, 7):
        answer.edit_cc(channel_id, user_id, 7)
    for channel_id in db.channel_change_all(user_id, 6, 7):
        answer.edit_cc(channel_id, user_id, 7)

    for channel_id in db.get_secret_channels("Market"):
        answer.edit_cc(channel_id, user_id, 4)

    for channel_id in db.get_secret_channels("Reporter"):
        if int(db_get(user_id, 'undead')) == 1:
            answer.msg(
                "{} - <@{}> had the role of the `Undead`!".format(
                    db_get(user_id, 'emoji'), user_id), channel_id)
        else:
            answer.msg(
                "{} - <@{}> had the role of the `{}`!".format(
                    db_get(user_id, 'emoji'), user_id,
                    db_get(user_id, 'role')), channel_id)

    # Kill that user already!
    db_set(user_id, 'role', 'Dead')
    db_set(user_id, 'fakerole', 'Dead')

    answer.spam(unip + 'kill <@{}>'.format(user_id))

    if int(db_get(user_id, 'abducted')) != 1 and role not in ["Barber"]:
        db.insert_deadie(user_id, deathType)

    # Kill all standoffs
    for taker in db.get_standoff(user_id):
        answer = attack(taker[1], taker[2], taker[3], answer, recursive)

    return answer
Ejemplo n.º 2
0
    def unabduct(self, user_id):
        """Unabduct a user.  
        This function alters the Mailbox, so 'add' and react commands may not work as intended."""
        db_set(user_id, 'abducted', 0)
        self.spam("<@{}> is no longer abducted.".format(user_id))

        for channel_id in channel_change_all(user_id, 3, 1):
            self.edit_cc(channel_id, user_id, 1)
        for channel_id in channel_change_all(user_id, 6, 5):
            self.edit_cc(channel_id, user_id, 5)
        for channel_id in channel_change_all(user_id, 7, 4):
            self.edit_cc(channel_id, user_id, 4)
        return self
Ejemplo n.º 3
0
    def abduct(self, user_id):
        """Abduct a user.  
        This function alters the Mailbox, so 'add' and react commands may not work as intended."""
        db_set(user_id, 'abducted', 1)
        self.spam("<@{}> has been abducted.".format(user_id))

        for channel_id in channel_change_all(user_id, 1, 3):
            self.edit_cc(channel_id, user_id, 3)
        for channel_id in channel_change_all(user_id, 5, 6):
            self.edit_cc(channel_id, user_id, 6)
        for channel_id in get_secret_channels('Swamp'):
            self.edit_cc(channel_id, user_id, 1)
        return self
Ejemplo n.º 4
0
def test_database():
    reset.reset(True)
    assert db.count_categories() == 0
    assert db.get_category() == None
    assert db.get_columns() == []
    assert db.poll_list() == []
    db.signup(1, 'Randium003', u':smirk:')
    assert db.get_user(1) == (1, u'Randium003', u':smirk:', 0, game_log,
                              'Spectator', 'Spectator', 0, 1, 0, 0, 0, 0, 0, 0,
                              0, 0, -1, 0, '', 0, 0, 0)
    assert db.db_get(1, 'channel') == game_log
    assert db.isParticipant(1) == False
    assert db.isParticipant(1, True) == True
    assert db.isParticipant(2) == False
    assert db.isParticipant(2, True) == False
    db.db_set(1, 'frozen', 1)
    assert db.poll_list() == [(1, u':smirk:', 1, 0)]

    db.add_category('24')
    assert db.count_categories() == 1
    assert db.get_category() == 24
    assert db.get_columns() == [(1, )]
    assert db.channel_get('1234555') == None
    db.add_channel('1234555', 1)
    assert db.get_category() == 24
    db.add_channel('12211', 1)
    assert db.get_category() == 24
    assert db.channel_get('1234555') == (u'1234555', u'1', u'0')
    assert db.channel_change_all(1, 0, 1) == [u'1234555', u'12211']
    assert db.channel_get('1234555') == (u'1234555', u'1', u'1')
    assert db.channel_get('12211') == (u'12211', u'1', u'1')
    db.set_user_in_channel('1234555', 1, 2)
    assert db.channel_get('1234555') == (u'1234555', u'1', u'2')
    assert db.channel_get('1234555', 1) == '2'
    assert db.channel_change_all(1, 2, 3) == [u'1234555']
    assert db.unabduct(1) == [u'1234555']
    db.signup(420, "BenTechy66", ":poop:")
    assert db.channel_get('12211') == (u'12211', u'1', u'1', u'0')
    assert db.freeze('1') == [u'1234555', u'12211']
    assert db.abduct('420') == []

    for i in range(max_channels_per_category - 2):
        assert db.get_category() == 24
        db.add_channel(10 * i, 608435446804 + 7864467 * i)
    assert db.count_categories() == 1
    assert db.get_category() == None
    reset.reset(True)
Ejemplo n.º 5
0
    def freeze(self, user_id):
        """Freeze a user.  
        This function alters the Mailbox, so 'add' and react commands may not work as intended."""
        db_set(user_id, 'frozen', 1)
        self.spam("<@{}> was frozen.".format(user_id))
        to_freeze = channel_change_all(user_id, 1, 2)

        for channel_id in get_secret_channels('Frozen_Realm'):
            self.edit_cc(channel_id, user_id, 1)
        for channel_id in to_freeze:
            self.edit_cc(channel_id, user_id, 2)
        return self
Ejemplo n.º 6
0
    def suspend(self, user_id):
        """Suspend a user.  
        This function alters the Mailbox, so 'add' and react commands may not work as intended."""
        db_set(user_id, 'role', 'Suspended')
        self.spam("<@{}> has been suspended.".format(user_id))

        for channel_id in channel_change_all(user_id, 1, 8):
            self.edit_cc(channel_id, user_id, 8)
        for channel_id in channel_change_all(user_id, 2, 8):
            self.edit_cc(channel_id, user_id, 8)
        for channel_id in channel_change_all(user_id, 3, 8):
            self.edit_cc(channel_id, user_id, 8)
        for channel_id in channel_change_all(user_id, 4, 8):
            self.edit_cc(channel_id, user_id, 8)
        for channel_id in channel_change_all(user_id, 5, 8):
            self.edit_cc(channel_id, user_id, 8)
        for channel_id in channel_change_all(user_id, 6, 8):
            self.edit_cc(channel_id, user_id, 8)
        for channel_id in channel_change_all(user_id, 7, 8):
            self.edit_cc(channel_id, user_id, 8)
        return self