Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Created January 9, 2014 07:01
Show Gist options
  • Save shiumachi/8330455 to your computer and use it in GitHub Desktop.
Save shiumachi/8330455 to your computer and use it in GitHub Desktop.
すごくシンプルな hipchat bot。リストに登録したメッセージを一定間隔でランダムに出力する。
# -*- coding: utf-8 -*-
import hypchat
import ConfigParser
import time
import random
config = ConfigParser.RawConfigParser()
config.read("config.ini")
TOKEN = config.get("account", "token")
ROOM_ID = config.get("room", "id")
hc = hypchat.HypChat(TOKEN)
room = hc.get_room(ROOM_ID)
#デフォルト: 30分間隔
INTERVAL = 30 * 60 * 1000
MESSAGES = [u"こんにちは",
u"さようなら",
u"ありがとう",
]
LEN_MESSAGES = len(MESSAGES)
while True:
room.message(MESSAGES[random.randint(0, LEN_MESSAGES - 1)])
time.sleep(INTERVAL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment