simplemachinesforum package

Submodules

simplemachinesforum.simplemachinesforum module

class simplemachinesforum.simplemachinesforum.SimpleMachinesForum(smf_url, smf_user, smf_pass)

Bases: object

Python API to SimpleMachinesForum

Parameters:
  • smf_url (str) – URL to the board

  • smf_user (str) – Username for the login

  • smf_pass (str) – Password for the login

Use the advanced search feature, and return the list of matches

Parameters:
  • boards (array of ints) – The boards to search IDs

  • search_term (str) – The search term to use.

  • users (array of strings) – The usernames to search for. * is all users

  • min_age (int) – Youngest posts in days to search for.

  • max_age (int) – Oldest posts in days to search for.

  • subject_only (int) – If to only search by subject. 0 for no, 1 for yes.

Returns:

List of topic ids that match the search

Return type:

array of ints, or None on error

get_stickied_posts(board)

Given a board, return the topic id for all currently stickied topics

Parameters:

board (int) – The board ID (e.g. ‘1’)

Returns:

the topic ids, or None on error

Return type:

array of ints/None

get_topic_id(board, subject)

Given a subject name and board, return the topic id for the matching topic.

Parameters:
  • board (int) – The board ID (e.g. ‘1’)

  • subject (str) – The subject of the existing topic.

Returns:

the topic’s id, or None on error

Return type:

int

new_topic(board, subject, msg, icon='xx', notify=0, lock=0, sticky=0)

Create a new topic on a remote simple machines forum over the network, all it needs is a valid user account to login.

Parameters:
  • board (int) – The board ID (e.g. ‘1’)

  • subject (str) – The subject of the new topic.

  • msg (str) – The body text of the new topic.

  • icon (str) – The topic icon, choose: xx = Standard, thumbup = Thumb Up, thumbdown = Thumb Down, exclamation = Exclamation point, question = Question mark, lamp = Lamp, smiley = Smiley, angry = Angry, cheesy = Cheesy, wink = Wink, grin = Grin, sad = Sad

  • notify (int) – Set notifications (0 = no, 1 = yes)

  • lock (int) – Lock the new topic (0 = no, 1 = yes)

  • sticky (int) – Set sticky (0 = no, 1 = yes)

Returns:

True or False

Return type:

bool

toggle_sticky(topic)

Given a topic ID, toggle the topic’s stickiness.

Parameters:

topic (int) – The topic ID (e.g. ‘1’)

Returns:

True or False

Return type:

bool

class simplemachinesforum.simplemachinesforum.SimpleMachinesForumAuth(smf, session)

Bases: object

Helper class for the SimpleMachienForum class, which handles all authentication (login/logout) This must be called upon the completion of every session/operation, since otherwise re-logging in will set a new, but invalid, PHPSESSID cookie Logging in and logging out every operation makes them idempotent, which costs more bandwidth/time but is easier then tracking login status/timeouts By implementing this class to support ‘with’, it can just be wrapped around each call to handle all authentication automatically

login()

Login to the account

logout()

Logout from the account

Module contents