diff --git a/slixmpp/plugins/__init__.py b/slixmpp/plugins/__init__.py
index 1c1b4717..c0ed34af 100644
--- a/slixmpp/plugins/__init__.py
+++ b/slixmpp/plugins/__init__.py
@@ -85,6 +85,7 @@ PLUGINS = [
# 'xep_0302', # XMPP Compliance Suites 2012. Don’t automatically load
'xep_0308', # Last Message Correction
'xep_0313', # Message Archive Management
+ 'xep_0317', # Hats
'xep_0319', # Last User Interaction in Presence
# 'xep_0323', # IoT Systems Sensor Data. Don’t automatically load
# 'xep_0325', # IoT Systems Control. Don’t automatically load
diff --git a/slixmpp/plugins/xep_0317/__init__.py b/slixmpp/plugins/xep_0317/__init__.py
new file mode 100644
index 00000000..836f3ff0
--- /dev/null
+++ b/slixmpp/plugins/xep_0317/__init__.py
@@ -0,0 +1,11 @@
+# Slixmpp: The Slick XMPP Library
+# This file is part of Slixmpp.
+# See the file LICENSE for copying permission.
+from slixmpp.plugins import register_plugin
+from slixmpp.plugins.xep_0317 import stanza
+from slixmpp.plugins.xep_0317.hats import XEP_0317
+from slixmpp.plugins.xep_0317.stanza import Hat, Hats
+
+register_plugin(XEP_0317)
+
+__all__ = ['stanza', 'XEP_317']
diff --git a/slixmpp/plugins/xep_0317/hats.py b/slixmpp/plugins/xep_0317/hats.py
new file mode 100644
index 00000000..79900557
--- /dev/null
+++ b/slixmpp/plugins/xep_0317/hats.py
@@ -0,0 +1,20 @@
+from slixmpp.plugins import BasePlugin
+from slixmpp import Presence
+from slixmpp.xmlstream import register_stanza_plugin
+from . import stanza
+
+
+class XEP_0317(BasePlugin):
+ """
+ XEP-0317: Hats
+ """
+
+ name = 'xep_0317'
+ description = 'XEP-0317: Hats'
+ dependencies = {'xep_0030', 'xep_0050'}
+ stanza = stanza
+ namespace = stanza.NS
+
+ def plugin_init(self):
+ register_stanza_plugin(stanza.Hat, stanza.Hats)
+ register_stanza_plugin(stanza.Hats, Presence)
diff --git a/slixmpp/plugins/xep_0317/stanza.py b/slixmpp/plugins/xep_0317/stanza.py
new file mode 100644
index 00000000..f049f6df
--- /dev/null
+++ b/slixmpp/plugins/xep_0317/stanza.py
@@ -0,0 +1,43 @@
+from slixmpp.xmlstream import ElementBase
+
+NS = 'urn:xmpp:hats:0'
+
+
+class Hats(ElementBase):
+ """
+ Hats element, container for multiple hats:
+
+ .. code-block::xml
+
+
+
+
+
+
+
+
+
+
+
+ """
+
+ name = 'hats'
+ namespace = NS
+ plugin_attrib = 'hats'
+
+
+class Hat(ElementBase):
+ """
+ Hat element, has a title and url, may contain arbitrary sub-elements.
+
+ .. code-block::xml
+
+
+
+
+
+ """
+ name = 'hat'
+ namespace = NS
+ plugin_attrib = 'hat'
+ interfaces = {'title', 'uri'}
diff --git a/tests/test_stanza_xep_0317.py b/tests/test_stanza_xep_0317.py
new file mode 100644
index 00000000..36dd0993
--- /dev/null
+++ b/tests/test_stanza_xep_0317.py
@@ -0,0 +1,31 @@
+import unittest
+from slixmpp import Presence
+from slixmpp.test import SlixTest
+import slixmpp.plugins.xep_0317 as xep_0317
+from slixmpp.xmlstream import register_stanza_plugin
+
+
+class TestStanzaHats(SlixTest):
+
+ def setUp(self):
+ register_stanza_plugin(Presence, xep_0317.Hats)
+ register_stanza_plugin(xep_0317.Hats, xep_0317.Hats)
+
+ def testCreateHats(self):
+ raw_xml = """
+
+
+
+ """
+
+ hats = xep_0317.Hats()
+
+ hat = xep_0317.Hat()
+ hat['uri'] = 'http://example.com/hats#Teacher'
+ hat['title'] = 'Teacher'
+ hats.append(hat)
+
+ self.check(hats, raw_xml, use_values=False)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestStanzaHats)