LunaTTvBot / LunaBot

0 stars 1 forks source link

Userrights #32

Closed iPaat closed 8 years ago

iPaat commented 8 years ago

With the Poll Plugin we developed a first plugin who needs extended rights. For example only Moderators and the Broadcaster should be able to manage polls. For a simple checking we need a "PermissionManager" who could map UserObjects and UserNames to Roles. I'm thinking of a simple static method PermissionManager.IsModearator("ipaat").

Base Roles are:

Where came the information of a role from? If the App is started the UserList will request the API for a list of chatters. This is necessary because the IRC UserList could only contain moderators for channels with more than 500 chatters. The API provides a nice list with chatters and their "Role" API Example. From there we could fire an event and give a list of moderators as EventArgs. This Event can be fired every minute if the channel runs in API Mode. Then we have every time a new list of moderators from the API. On channels where we don't need the API Mode the "PermissionManager" could listen to the operator grated and revoked events from the ChannelEventsManager to keep the list up to date after the first API call.
Where we could get the Follower, Subscriber and Streamer information from, I don't really know. The Streamer has to tell his name to the Bot ( @CapCalamity , @SupremeVoid ideas?). Subscriber and Follower could be requested from official Twitch API. But I think it would be easier to request a list of Followers of a channel once the Bot started and keep it up to date by events. Same for subscribers.

For later: It would be nice to have the possibility to add new Roles (Groups?) they could be stored into our database ( #31 ). Then we could check permission like PermissionManager.HasRole("CanSongRequest"). Roles should be registrable from Plugins so that a Plugin can provide Roles and the bot owner can map them in a nice user interface to users and Base Roles.

CapCalamity commented 8 years ago

Can we not take the streamers name from the config?

settings.example.json

{
  "owner_nickname": "",
  "owner_username": "", 
  "owner_apikey": "",
  "bot_nickname": "",
  "bot_username": "",
  "bot_apikey": "",
  "port": 6667,
  "url": "irc.chat.twitch.tv",
  "channel_list": [
    "twitch"
  ]
}

owner_nickname would be the name we search for in the userlist, owner_username would be the display name.

As for Followers / Subscribers, twitch offers these API endpoints that list the requested users per channel:

The result would be that a PermissionManager would:

Maybe we can integrate this with #43 so that we have one dedicated class for this stuff, instead of multiple classes that kinda do the same thing.

CapCalamity commented 8 years ago

Now that I am working on this issue I realize that we probably need to access the official Twitch API more often.
I will open another issue to implement the Twitch API then, after that is done, I will continue working on this issue.