Skip to content

Instantly share code, notes, and snippets.

@endofline
endofline / run-hangupsbot.sh
Last active August 29, 2015 14:14
psuedo-daemonised bot (infinite bash loop)
#!/bin/bash
while true
do
# blocking call until SIGINT received or /bot quit
python3 -u /<username>/bot/hangupsbot/hangupsbot.py -d > /<username>/bot-stdout.log
# sleep 3
done
@endofline
endofline / memory
Last active August 29, 2015 14:14
annotated structure
{
// bot.conversation_memory_set(<event.conv_id>, <keyname>)
// bot.conversation_memory_get(<event.conv_id>, <keyname>)
// <event.conv_id> can be CONVERSATION_ID_1, CONVERSATION_ID_2 etc
// <keyname> would be "somekey1", "somekey2", etc
// bot.memory.exists(["conv_data", "CONVERSATION_ID_1", "somekey1"]) returns true
// bot.memory.exists(["conv_data", "CONVERSATION_ID_1", "somekey5"]) returns false
"conv_data": {
"CONVERSATION_ID_1": {
@endofline
endofline / memory fragment search
Created February 7, 2015 04:31
pseudo-python for iterating through a list of conversation memories
@endofline
endofline / simplytranslate.py
Created February 9, 2015 11:23
10 minutes of Python code
import goslate
import asyncio
gs = goslate.Goslate()
def _initialise(command):
command.register_handler(_handle_message)
@asyncio.coroutine
def _handle_message(bot, event, command):
@endofline
endofline / urbandict.py
Created February 12, 2015 02:19
urban dictionary plugin for hangoutsbot
#
# Simple interface to urbandictionary.com
#
# Author: Roman Bogorodskiy <bogorodskiy@gmail.com>
import sys
from urllib.request import urlopen
from urllib.parse import quote as urlquote
from html.parser import HTMLParser
@endofline
endofline / wolframalpha.py
Created March 16, 2015 12:21
Experimental Wolfram Alpha Plugin based on billius's original gist
"""
simple "ask" function for wolfram alpha data
* pip3 install wolframalpha
* get API KEY from http://products.wolframalpha.com/developers/
* put API KEY in config.json:wolframalpha-apikey
"""
import wolframalpha
_internal = {}
@endofline
endofline / example_modern.py
Created April 21, 2015 09:45
functionally-identical hangouts bot plugins (version 2.4 and above)
"""standard plugin
more documentation: __wikilink__
"""
import plugins
def _initialise(bot):
plugins.register_admin_command(["noop_standard"])
plugins.register_handler(_handle_nothing)
@endofline
endofline / convtools_public.py
Last active August 29, 2015 14:24
Conversation Tools: Public Channels (Proof of Concept)
import hangups
import plugins
def _initialise(bot):
plugins.register_user_command(["public"])
def public(bot, event, *args):
"""list all available public channels when called without any parameters.
to join a channel, call this command with the desired channel number"""
@endofline
endofline / testing_convmem.py
Created July 2, 2015 07:48
Conversation Memory (Alpha)
import datetime
import plugins
from hangups.ui.utils import get_conv_name
convmem = {}
def _initialise(bot):
_memory_load(bot)
@endofline
endofline / testing_logging.py
Created July 8, 2015 03:10
[hangoutsbot] stream handler example to dump all logs straight to stdout
import sys, logging
def _initialise(bot):
consoleHandler = logging.StreamHandler(stream=sys.stdout)
format = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
consoleHandler.setFormatter(format)
rootLogger = logging.getLogger()
rootLogger.addHandler(consoleHandler)