Skip to content

Administering users from shell

kiwiheretic edited this page May 9, 2016 · 6 revisions

Using the admin command

Initial setup

It is now possible to set up individual users with very specific permissions (thanks to Django Guardian permission system).

First you will need to add your own nick as user replacing <username>, <email> and <password> with the appropriate information. Then set yourself as superuser.

$ python manage.py admin adduser <username> <email> <password>
$ python manage.py admin setsuperuser <username>

Now when you login you type on IRC network (preferrable in private window to the bot) something like the following:

/nick <username>
!login <password>

You can change your own password later on with:

!set password <newpassword>

Again this should be done in a private window to bot for security reasons.

If you forget your password and need to reset it you can reset it from the shell like this:

$ python manage.py admin setpass <username> <password>

Adding Users

You add users by using the command

$ python manage.py admin adduser <username> <email> <password>

What does <network> refer to?

Read this to avoid some confusion: I add this section because there seems to be some confusion what is meant by <network>. It always refers to the IRC server, not the network the hosting computer is part of. Perhaps it would have been better to name it <IRC-server-name> in hindsight. It needs to match the server name that was entered on the command line when starting the bot (the -s option).

Assigning Permissions

$ python manage.py admin assignperm <network> <channel> <username> <capability>

You can get a list of all capabilities by typing:

$ python manage.py admin listperms

with sample output shown below:

Network Permissions
  bot_admin, Create user logins and assign permissions
  join_or_part_room, Join or part bot to rooms
  irc_cmd, Issue arbitrary command to bot
  set_pvt_version, Set bible version default in private chat window
  change_pvt_trigger, Set trigger used in private chat window

Room Permissions
  room_admin, Assign permissions to existing users of own room
  change_trigger, Change trigger
  set_default_translation, Set default room translation
  set_verse_limits, Set room verse limits
  set_greeting, Set room greeting message
  can_speak, Speak through bot
  start_game, Can start scripture game

Network permissions are permissions that apply to the entire IRC network whilst room permissions only apply to the room specified. To assign a network permission the syntax is:

$ python manage.py admin assignperm <network> '#' <username> <capability>

or in the case of windows ...

C:\path\to\bot> python manage.py admin assignperm <network> # <username> <capability>

To assign a room permission you specify a room name instead of the #.

$ python manage.py admin assignperm <network> <room> <username> <capability>

To remove a permission (capability) from username it is 'unassignperm' as follows:

$ python manage.py admin unassignperm <network> <room> <username> <capability>

To see permissions (capabilities) assigned to a given user ...

$ python manage.py admin getperms <username>