News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Pulling in Mibbit chatroom user count in menu

Started by numsix, July 03, 2015, 03:37:49 AM

Previous topic - Next topic

numsix

We use Mibbit for a gateway to an IRC chatroom.

Mibbit has an API that will allow you to pull in the number of users in the chatroom using various methods. For example there's javascript which will give you a document.write("x") result with your current chatroom number. There's also a url you can pull that will return your exact number of users.

I was wondering if anyone had any ideas on how this could be integrated with SMF to give you the user count next to the link in the menu bar? ie like the PM link has your unread PMs?


Gluz

The Mibbit API says it updates that number every 20 minutes, but for me is not working, always shows 0 and have 2 users for like an hour or so.


This depends on where and how you add the button to the mibbit widget, as I have it as a SimplePortal page and the link is in the main menu by edit the $buttons array:

'chat_irc' => array(
'title' => $txt['Chat_irc'] . ' [ ' . file_get_contents('http://api.mibbit.com/<your settings ID>') . ']',
    'href' => $scripturl . '?page=chat_irc',
'show' => true,
'sub_buttons' => array(
),
  ),


This shows in the main menu as:   Chat [ 0 ]

NOTE: your settings ID is a long alphanumeric thing that is in the widget.


Also for show it only when users are connected in the chat:
'title' => $txt['Chat_irc'] . (((int)file_get_contents('http://api.mibbit.com/<your settings ID>')>0) ? ' [ ' . file_get_contents('http://api.mibbit.com/<your settings ID>') . ']' : '')

Advertisement: