2022-11-14 22:43:45 +01:00
<!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / > < meta name = "generator" content = "Docutils 0.17.1: http://docutils.sourceforge.net/" / >
2023-10-19 20:22:27 +00:00
< title > Connect Evennia to Twitter — Evennia 2.x documentation< / title >
2022-11-14 22:43:45 +01:00
< link rel = "stylesheet" href = "../_static/nature.css" type = "text/css" / >
< link rel = "stylesheet" href = "../_static/pygments.css" type = "text/css" / >
< script id = "documentation_options" data-url_root = "../" src = "../_static/documentation_options.js" > < / script >
< script src = "../_static/jquery.js" > < / script >
< script src = "../_static/underscore.js" > < / script >
< script src = "../_static/doctools.js" > < / script >
< script src = "../_static/language_data.js" > < / script >
< link rel = "shortcut icon" href = "../_static/favicon.ico" / >
< link rel = "index" title = "Index" href = "../genindex.html" / >
< link rel = "search" title = "Search" href = "../search.html" / >
2022-11-22 17:04:56 +00:00
< link rel = "next" title = "Evennia Game Index" href = "Evennia-Game-Index.html" / >
< link rel = "prev" title = "Connect Evennia channels to RSS" href = "Channels-to-RSS.html" / >
2022-11-14 22:43:45 +01:00
< / head > < body >
2023-10-19 20:22:27 +00:00
2022-11-14 22:43:45 +01:00
< div class = "related" role = "navigation" aria-label = "related navigation" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../genindex.html" title = "General Index"
accesskey="I">index< / a > < / li >
< li class = "right" >
< a href = "../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
< li class = "right" >
2022-11-22 17:04:56 +00:00
< a href = "Evennia-Game-Index.html" title = "Evennia Game Index"
2022-11-14 22:43:45 +01:00
accesskey="N">next< / a > |< / li >
< li class = "right" >
2022-11-22 17:04:56 +00:00
< a href = "Channels-to-RSS.html" title = "Connect Evennia channels to RSS"
2022-11-14 22:43:45 +01:00
accesskey="P">previous< / a > |< / li >
2023-10-19 20:22:27 +00:00
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Evennia 2.x< / a > » < / li >
2022-11-14 22:43:45 +01:00
< li class = "nav-item nav-item-1" > < a href = "Setup-Overview.html" accesskey = "U" > Server Setup and Life< / a > » < / li >
2022-11-22 17:04:56 +00:00
< li class = "nav-item nav-item-this" > < a href = "" > Connect Evennia to Twitter< / a > < / li >
2022-11-14 22:43:45 +01:00
< / ul >
2023-06-10 08:53:19 +00:00
< / div >
2022-11-14 22:43:45 +01:00
< div class = "document" >
< div class = "documentwrapper" >
< div class = "sphinxsidebar" role = "navigation" aria-label = "main navigation" >
< div class = "sphinxsidebarwrapper" >
< p class = "logo" > < a href = "../index.html" >
< img class = "logo" src = "../_static/evennia_logo.png" alt = "Logo" / >
< / a > < / p >
< div id = "searchbox" style = "display: none" role = "search" >
< h3 id = "searchlabel" > Quick search< / h3 >
< div class = "searchformwrapper" >
< form class = "search" action = "../search.html" method = "get" >
< input type = "text" name = "q" aria-labelledby = "searchlabel" / >
< input type = "submit" value = "Go" / >
< / form >
< / div >
< / div >
< script > $ ( '#searchbox' ) . show ( 0 ) ; < / script >
< h3 > < a href = "../index.html" > Table of Contents< / a > < / h3 >
< ul >
2022-11-22 17:04:56 +00:00
< li > < a class = "reference internal" href = "#" > Connect Evennia to Twitter< / a > < ul >
2022-11-14 22:43:45 +01:00
< li > < a class = "reference internal" href = "#configuring-twitter" > Configuring Twitter< / a > < / li >
2022-11-22 17:04:56 +00:00
< li > < a class = "reference internal" href = "#setting-up-twitter-step-by-step" > Setting up Twitter, step by step< / a > < ul >
2022-11-14 22:43:45 +01:00
< li > < a class = "reference internal" href = "#a-basic-tweet-command" > A basic tweet command< / a > < / li >
< li > < a class = "reference internal" href = "#next-steps" > Next Steps< / a > < / li >
< / ul >
< / li >
2022-11-22 17:04:56 +00:00
< / ul >
< / li >
2022-11-14 22:43:45 +01:00
< / ul >
< h4 > Previous topic< / h4 >
2022-11-22 17:04:56 +00:00
< p class = "topless" > < a href = "Channels-to-RSS.html"
title="previous chapter">Connect Evennia channels to RSS< / a > < / p >
2022-11-14 22:43:45 +01:00
< h4 > Next topic< / h4 >
2022-11-22 17:04:56 +00:00
< p class = "topless" > < a href = "Evennia-Game-Index.html"
title="next chapter">Evennia Game Index< / a > < / p >
2022-11-14 22:43:45 +01:00
< div role = "note" aria-label = "source link" >
<!-- h3>This Page</h3 -->
< ul class = "this-page-menu" >
2022-11-22 17:04:56 +00:00
< li > < a href = "../_sources/Setup/Channels-to-Twitter.md.txt"
2022-11-14 22:43:45 +01:00
rel="nofollow">Show Page Source< / a > < / li >
< / ul >
< / div > < h3 > Links< / h3 >
< ul >
2023-10-19 20:22:27 +00:00
< li > < a href = "https://www.evennia.com/docs/latest/index.html" > Documentation Top< / a > < / li >
< li > < a href = "https://www.evennia.com" > Evennia Home< / a > < / li >
< li > < a href = "https://github.com/evennia/evennia" > Github< / a > < / li >
2022-11-14 22:43:45 +01:00
< li > < a href = "http://games.evennia.com" > Game Index< / a > < / li >
< li >
< a href = "https://discord.gg/AJJpcRUhtF" > Discord< / a > -
< a href = "https://github.com/evennia/evennia/discussions" > Discussions< / a > -
< a href = "https://evennia.blogspot.com/" > Blog< / a >
< / li >
< / ul >
2023-10-19 20:22:27 +00:00
< h3 > Doc Versions< / h3 >
2022-11-14 22:43:45 +01:00
< ul >
2023-10-19 20:22:27 +00:00
< li > < a href = "Channels-to-Twitter.html" > 2.x (main branch)< / a > < / li >
2022-11-15 20:29:38 +00:00
< ul >
2023-10-19 20:22:27 +00:00
< li > < a href = "../1.3.0/index.html" > 1.3.0 (v1.3.0 branch)< / a > < / li >
< li > < a href = "../0.9.5/index.html" > 0.9.5 (v0.9.5 branch)< / a > < / li >
2022-11-15 20:29:38 +00:00
2022-11-14 22:43:45 +01:00
< / ul >
< / div >
< / div >
< div class = "bodywrapper" >
< div class = "body" role = "main" >
2022-11-22 17:04:56 +00:00
< section class = "tex2jax_ignore mathjax_ignore" id = "connect-evennia-to-twitter" >
< h1 > Connect Evennia to Twitter< a class = "headerlink" href = "#connect-evennia-to-twitter" title = "Permalink to this headline" > ¶< / a > < / h1 >
< p > < a class = "reference external" href = "https://en.wikipedia.org/wiki/twitter" > Twitter< / a > is an online social networking service that enables users to send and read short messages called “tweets”. Following is a short tutorial explaining how to enable users to send tweets from inside Evennia.< / p >
2022-11-14 22:43:45 +01:00
< section id = "configuring-twitter" >
< h2 > Configuring Twitter< a class = "headerlink" href = "#configuring-twitter" title = "Permalink to this headline" > ¶< / a > < / h2 >
2022-11-22 17:04:56 +00:00
< p > You must first have a Twitter account. Log in and register an App at the < a class = "reference external" href = "https://apps.twitter.com/" > Twitter Dev Site< / a > . Make sure you enable access to “write” tweets!< / p >
< p > To tweet from Evennia you will need both the “API Token” and the “API secret” strings as well as the “Access Token” and “Access Secret” strings.< / p >
< p > Twitter changed their requirements to require a Mobile number on the Twitter account to register new apps with write access. If you’ re unable to do this, please see < a class = "reference external" href = "https://dev.twitter.com/notifications/new-apps-registration" > this Dev post< / a > which describes how to get around it.< / p >
2022-11-14 22:43:45 +01:00
< p > To use Twitter you must install the < a class = "reference external" href = "https://pypi.python.org/pypi/twitter" > Twitter< / a > Python module:< / p >
< div class = "highlight-default notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "n" > pip< / span > < span class = "n" > install< / span > < span class = "n" > python< / span > < span class = "o" > -< / span > < span class = "n" > twitter< / span >
< / pre > < / div >
< / div >
< / section >
2022-11-22 17:04:56 +00:00
< section id = "setting-up-twitter-step-by-step" >
< h2 > Setting up Twitter, step by step< a class = "headerlink" href = "#setting-up-twitter-step-by-step" title = "Permalink to this headline" > ¶< / a > < / h2 >
2022-11-14 22:43:45 +01:00
< section id = "a-basic-tweet-command" >
2022-11-22 17:04:56 +00:00
< h3 > A basic tweet command< a class = "headerlink" href = "#a-basic-tweet-command" title = "Permalink to this headline" > ¶< / a > < / h3 >
< p > Evennia doesn’ t have a < code class = "docutils literal notranslate" > < span class = "pre" > tweet< / span > < / code > command out of the box so you need to write your own little < a class = "reference internal" href = "../Components/Commands.html" > < span class = "doc std std-doc" > Command< / span > < / a > in order to tweet. If you are unsure about how commands work and how to add them, it can be an idea to go through the < a class = "reference internal" href = "../Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Adding-Commands.html" > < span class = "doc std std-doc" > Adding a Command Tutorial< / span > < / a > before continuing.< / p >
< p > You can create the command in a separate command module (something like < code class = "docutils literal notranslate" > < span class = "pre" > mygame/commands/tweet.py< / span > < / code > ) or together with your other custom commands, as you prefer.
This is how it can look:< / p >
< div class = "highlight-python notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "c1" > # in mygame/commands.tweet.py, for example< / span >
< span class = "kn" > import< / span > < span class = "nn" > twitter< / span >
2022-11-14 22:43:45 +01:00
< span class = "kn" > from< / span > < span class = "nn" > evennia< / span > < span class = "kn" > import< / span > < span class = "n" > Command< / span >
< span class = "c1" > # here you insert your unique App tokens< / span >
< span class = "c1" > # from the Twitter dev site< / span >
< span class = "n" > TWITTER_API< / span > < span class = "o" > =< / span > < span class = "n" > twitter< / span > < span class = "o" > .< / span > < span class = "n" > Api< / span > < span class = "p" > (< / span > < span class = "n" > consumer_key< / span > < span class = "o" > =< / span > < span class = "s1" > ' api_key' < / span > < span class = "p" > ,< / span >
< span class = "n" > consumer_secret< / span > < span class = "o" > =< / span > < span class = "s1" > ' api_secret' < / span > < span class = "p" > ,< / span >
< span class = "n" > access_token_key< / span > < span class = "o" > =< / span > < span class = "s1" > ' access_token_key' < / span > < span class = "p" > ,< / span >
< span class = "n" > access_token_secret< / span > < span class = "o" > =< / span > < span class = "s1" > ' access_token_secret' < / span > < span class = "p" > )< / span >
< span class = "k" > class< / span > < span class = "nc" > CmdTweet< / span > < span class = "p" > (< / span > < span class = "n" > Command< / span > < span class = "p" > ):< / span >
2023-01-06 17:19:13 +00:00
< span class = "w" > < / span > < span class = "sd" > " " " < / span >
2022-11-14 22:43:45 +01:00
< span class = "sd" > Tweet a message< / span >
< span class = "sd" > Usage: < / span >
< span class = "sd" > tweet < message> < / span >
< span class = "sd" > This will send a Twitter tweet to a pre-configured Twitter account.< / span >
< span class = "sd" > A tweet has a maximum length of 280 characters. < / span >
< span class = "sd" > " " " < / span >
< span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "s2" > " tweet" < / span >
< span class = "n" > locks< / span > < span class = "o" > =< / span > < span class = "s2" > " cmd:pperm(tweet) or pperm(Developers)" < / span >
< span class = "n" > help_category< / span > < span class = "o" > =< / span > < span class = "s2" > " Comms" < / span >
< span class = "k" > def< / span > < span class = "nf" > func< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "s2" > " This performs the tweet" < / span >
< span class = "n" > caller< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > caller< / span >
< span class = "n" > tweet< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > args< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > tweet< / span > < span class = "p" > :< / span >
< span class = "n" > caller< / span > < span class = "o" > .< / span > < span class = "n" > msg< / span > < span class = "p" > (< / span > < span class = "s2" > " Usage: tweet < message> " < / span > < span class = "p" > )< / span >
< span class = "k" > return< / span >
< span class = "n" > tlen< / span > < span class = "o" > =< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "n" > tweet< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > tlen< / span > < span class = "o" > > < / span > < span class = "mi" > 280< / span > < span class = "p" > :< / span >
< span class = "n" > caller< / span > < span class = "o" > .< / span > < span class = "n" > msg< / span > < span class = "p" > (< / span > < span class = "sa" > f< / span > < span class = "s2" > " Your tweet was < / span > < span class = "si" > {< / span > < span class = "n" > tlen< / span > < span class = "si" > }< / span > < span class = "s2" > chars long (max 280)." < / span > < span class = "p" > )< / span >
< span class = "k" > return< / span >
< span class = "c1" > # post the tweet < / span >
< span class = "n" > TWITTER_API< / span > < span class = "o" > .< / span > < span class = "n" > PostUpdate< / span > < span class = "p" > (< / span > < span class = "n" > tweet< / span > < span class = "p" > )< / span >
< span class = "n" > caller< / span > < span class = "o" > .< / span > < span class = "n" > msg< / span > < span class = "p" > (< / span > < span class = "sa" > f< / span > < span class = "s2" > " You tweeted:< / span > < span class = "se" > \n< / span > < span class = "si" > {< / span > < span class = "n" > tweet< / span > < span class = "si" > }< / span > < span class = "s2" > " < / span > < span class = "p" > )< / span >
< / pre > < / div >
< / div >
< p > Be sure to substitute your own actual API/Access keys and secrets in the appropriate places.< / p >
2022-11-22 17:04:56 +00:00
< p > We default to limiting tweet access to players with < code class = "docutils literal notranslate" > < span class = "pre" > Developers< / span > < / code > -level access < em > or< / em > to those players that have the permission “tweet”< / p >
< p > To allow allow individual characters to tweet, set the < code class = "docutils literal notranslate" > < span class = "pre" > tweet< / span > < / code > permission with< / p >
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > perm/player playername = tweet
< / pre > < / div >
< / div >
< p > You may change the < a class = "reference internal" href = "../Components/Locks.html" > < span class = "doc std std-doc" > lock< / span > < / a > as you feel is appropriate. Change the overall permission to < code class = "docutils literal notranslate" > < span class = "pre" > Players< / span > < / code > if you want everyone to be able to tweet.< / p >
< p > Now add this command to your default command set (e.g in < code class = "docutils literal notranslate" > < span class = "pre" > mygame/commands/defalt_cmdsets.py< / span > < / code > ) and < code class = "docutils literal notranslate" > < span class = "pre" > reload< / span > < / code > the server. From now on those with access can simply use < code class = "docutils literal notranslate" > < span class = "pre" > tweet< / span > < span class = "pre" > < message> < / span > < / code > to see the tweet posted from the game’ s Twitter account.< / p >
2022-11-14 22:43:45 +01:00
< / section >
< section id = "next-steps" >
2022-11-22 17:04:56 +00:00
< h3 > Next Steps< a class = "headerlink" href = "#next-steps" title = "Permalink to this headline" > ¶< / a > < / h3 >
2022-11-14 22:43:45 +01:00
< p > This shows only a basic tweet setup, other things to do could be:< / p >
< ul class = "simple" >
< li > < p > Auto-Adding the character name to the tweet< / p > < / li >
< li > < p > More error-checking of postings< / p > < / li >
< li > < p > Changing locks to make tweeting open to more people< / p > < / li >
< li > < p > Echo your tweets to an in-game channel< / p > < / li >
< / ul >
2022-11-23 20:20:36 +00:00
< p > Rather than using an explicit command you can set up a Script to send automatic tweets, for example to post updated game stats. See the < a class = "reference internal" href = "../Howtos/Web-Tweeting-Game-Stats.html" > < span class = "doc std std-doc" > Tweeting Game Stats tutorial< / span > < / a > for help.< / p >
2022-11-22 17:04:56 +00:00
< / section >
2022-11-14 22:43:45 +01:00
< / section >
< / section >
< / div >
< / div >
< / div >
< / div >
< div class = "related" role = "navigation" aria-label = "related navigation" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../genindex.html" title = "General Index"
>index< / a > < / li >
< li class = "right" >
< a href = "../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
< li class = "right" >
2022-11-22 17:04:56 +00:00
< a href = "Evennia-Game-Index.html" title = "Evennia Game Index"
2022-11-14 22:43:45 +01:00
>next< / a > |< / li >
< li class = "right" >
2022-11-22 17:04:56 +00:00
< a href = "Channels-to-RSS.html" title = "Connect Evennia channels to RSS"
2022-11-14 22:43:45 +01:00
>previous< / a > |< / li >
2023-10-19 20:22:27 +00:00
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Evennia 2.x< / a > » < / li >
2022-11-14 22:43:45 +01:00
< li class = "nav-item nav-item-1" > < a href = "Setup-Overview.html" > Server Setup and Life< / a > » < / li >
2022-11-22 17:04:56 +00:00
< li class = "nav-item nav-item-this" > < a href = "" > Connect Evennia to Twitter< / a > < / li >
2022-11-14 22:43:45 +01:00
< / ul >
< / div >
2023-10-19 20:22:27 +00:00
2022-11-14 22:43:45 +01:00
< div class = "footer" role = "contentinfo" >
2023-10-19 20:22:27 +00:00
© Copyright 2023, The Evennia developer community.
2022-11-14 22:43:45 +01:00
Created using < a href = "https://www.sphinx-doc.org/" > Sphinx< / a > 3.2.1.
< / div >
< / body >
< / html >