thankyou
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here

NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

Author Topic: Kick Event Issue  (Read 360 times)

Offline st0rm

  • Newbie
  • *
  • Posts: 2
Kick Event Issue
« on: October 30, 2016, 11:39:05 PM »
Hey,

I am kinda working on making a discord bot that post when people get kicked, banned into a discord server. I found some code from mamba of his twitter banned and modified to my needs. I can't seem to get the admin that kicked/banned or the reason for the penalty. Code break when this gets called.
Code: [Select]
 admin = b3.clients.getByCID(p.adminId)

this is the error
161030 17:32:17 ERROR    "Handler DiscordbanPlugin could not handle event Client Kicked: AttributeError: 'module' object has no attribute 'getByCID' [('C:\\\\Games\\\\Cod4HNS\\\\b3\\\\b3\\\\parser.py', 1412, 'handleEvents', 'hfunc.parseEvent(event)'), ('C:\\\\Games\\\\Cod4HNS\\\\b3\\\\b3\\\\plugin.py', 479, 'parseEvent', 'func(event)'), ('C:\\\\Games\\\\Cod4HNS\\\\b3\\\\b3\\\\extplugins\\\\discordban.py', 77, 'onEvent', 'admin = b3.clients.getByCID(p.adminId)')]"


action = ''

    if event.type == b3.events.EVT_CLIENT_KICK:
   action = 'kicked'

    if event.type == b3.events.EVT_CLIENT_BAN_TEMP:
   action = 'banned'

    if event.type == b3.events.EVT_CLIENT_BAN:
   action = 'banned'

    p = self.getLastBanKick(event.client)
    clientName = event.client.name
    admin = b3.clients.getByCID(p.adminId)
    self.debug('Posting Update to discord: %s' % admin.admin)
    text = '%s %s %s' % (self.removeColors(admin.name), action, clientName)
    self.debug('Posting Update to discord: %s' % text)
    text = '%s: for %s' % (text, self.removeColors(p.reason))

  def getLastBanKick(self, client):
    q = "select * from `penalties` where client_id = %i and type in ('Ban', 'TempBan', 'Kick') order by time_add desc limit 1 " % client.id
    self.debug(q)
    cursor = self.console.storage.query(q)
    g = cursor.getOneRow()
    self.debug(q)
    if not g:
      self.debug('Nothing found')
    return None
    self.debug('Found at least one row: %s' % (str(g)))

    penalty = b3.clients.Penalty()
    penalty.id = int(g['id'])
    penalty.type = g['type']
    penalty.keyword = g['keyword']
    penalty.reason = g['reason']
    penalty.data = g['data']
    penalty.duration = g['duration']
    penalty.inactive = int(g['inactive'])
    penalty.timeAdd  = int(g['time_add'])
    penalty.timeEdit = int(g['time_edit'])
    penalty.timeExpire = int(g['time_expire'])
    penalty.clientId = int(g['client_id'])
    penalty.adminId = int(g['admin_id'])

    return penalty

Any idea how to fix this?
« Last Edit: October 31, 2016, 12:16:17 AM by st0rm »

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2503
Re: Kick Event Issue
« Reply #1 on: October 31, 2016, 12:27:49 AM »
Try:

self.plugin.console.clients.getByCID(cid)

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 981
    • GitHub
Re: Kick Event Issue
« Reply #2 on: November 02, 2016, 11:41:46 AM »
Try:

self.plugin.console.clients.getByCID(cid)
I suggest self.console.clients.getByCID(cid), since he's already referring to the parser using self.console :)

 


Rate this page +1 at Google Search